Skip to content

Instantly share code, notes, and snippets.

@nesk
Last active June 20, 2019 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesk/343d78c13eee91355e999877d3518eb6 to your computer and use it in GitHub Desktop.
Save nesk/343d78c13eee91355e999877d3518eb6 to your computer and use it in GitHub Desktop.
PHPUnit - Data providers memory showcase
/vendor
composer.lock
{
"require": {
"phpunit/phpunit": "8.2.3"
}
}
<?php
use PHPUnit\Framework\TestCase;
class DataProvidersMemoryTest extends TestCase
{
/** @dataProvider stringProvider */
public function testStringComplies(string $string): void
{
self::assertStringStartsWith('data:', $string);
}
public function stringProvider(): \Traversable
{
for ($i = 0 ; $i < 10000 ; $i++) {
yield ['data:'.str_repeat('a', 8192)];
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.2/phpunit.xsd"
backupGlobals="false"
cacheResult="false"
>
<testsuites>
<testsuite name="Project Test Suite">
<file>./DataProvidersMemoryTest.php</file>
</testsuite>
</testsuites>
</phpunit>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment