1. Go to this page and download the library: Download symplify/easy-testing library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
symplify / easy-testing example snippets
echo 'content before';
echo 'just this content';
// tests/SomeTest/SomeTest.php
namespace App\Tests\SomeTest;
use Iterator;
use PHPUnit\Framework\TestCase;
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
use Symplify\EasyTesting\StaticFixtureSplitter;
use Symplify\SmartFileSystem\SmartFileInfo;
final class SomeTest extends TestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fileInfo): void
{
$inputAndExpected = StaticFixtureSplitter::splitFileInfoToInputAndExpected($fileInfo);
// test before content
$someService = new SomeService();
$changedContent = $someService->process($inputAndExpected->getInput());
$this->assertSame($inputAndExpected->getExpected(), $changedContent);
}
public function provideData(): Iterator
{
return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture');
}
}
use Symplify\EasyTesting\StaticFixtureSplitter;
$inputFileInfoAndExpectedFileInfo = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos(
$fileInfo,
true
);
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture');
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture', '*.md');
use PHPUnit\Framework\TestCase;
use Symplify\EasyTesting\DataProvider\StaticFixtureUpdater;
use Symplify\EasyTesting\StaticFixtureSplitter;
use Symplify\SmartFileSystem\SmartFileInfo;
final class SomeTestCase extends TestCase
{
/**
* @dataProvider provideData()
*/
public function test(SmartFileInfo $fixtureFileInfo): void
{
$inputFileInfoAndExpectedFileInfo = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos(
$fixtureFileInfo
);
// process content
$currentContent = '...';
// here we update test fixture if the content changed
StaticFixtureUpdater::updateFixtureContent(
$inputFileInfoAndExpectedFileInfo->getInputFileInfo(),
$currentContent,
$fixtureFileInfo
);
}
// data provider...
}
use PHPUnit\Framework\TestCase;
use Symplify\EasyTesting\PHPUnit\Behavior\DirectoryAssertableTrait;
final class DirectoryAssertableTraitTest extends TestCase
{
use DirectoryAssertableTrait;
public function testSuccess(): void
{
$this->assertDirectoryEquals(__DIR__ . '/Fixture/first_directory', __DIR__ . '/Fixture/second_directory');
}
}