PHP code example of symplify / easy-coding-standard-tester

1. Go to this page and download the library: Download symplify/easy-coding-standard-tester 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-coding-standard-tester example snippets


namespace Your\CodingStandard\Tests\Fixer\YourFixer;

use Iterator;
use Symplify\EasyCodingStandardTester\Testing\AbstractCheckerTestCase;
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
use Symplify\SmartFileSystem\SmartFileInfo;
use Your\CondingStandard\Fixer\YourFixer;

final class YourFixerTest extends AbstractCheckerTestCase
{
    /**
     * @dataProvider provideData()
     */
    public function test(SmartFileInfo $fileInfo): void
    {
        $this->doTestFileInfo($fileInfo);
    }

    public function provideData(): Iterator
    {
        return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture');
    }

    /**
     * @dataProvider provideDataWithFileErrors()
     */
    public function testFileErrors(SmartFileInfo $fileInfo, int $expectedErrorCount): void
    {
        $this->doTestFileInfoWithErrorCountOf($fileInfo, $expectedErrorCount);
    }

    public function provideDataWithFileErrors(): Iterator
    {
        yield [new SmartFileInfo(__DIR__ . '/Fixture/wrong.php.inc'), 1];
        yield [new SmartFileInfo(__DIR__ . '/Fixture/correct.php.inc'), 0];
    }

    protected function getCheckerClass(): string
    {
        return YourFixer::class;
    }
}



$array = array();