2017 © Pedro Peláez
 

library easy-coding-standard-tester

# The Best Way to Test Sniffs and Fixers

image

symplify/easy-coding-standard-tester

# The Best Way to Test Sniffs and Fixers

  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 22 Versions
  • 229 % Grown

The README.md

The Best Way to Test Fixers and Sniffs

Downloads total, (*1)

Do you write your own fixer and sniffs? Would you like to test them without having to learn a lot about their internals?, (*2)

This package make fixer and sniff testing with 1 single approach super easy., (*3)

Install

composer require symplify/easy-coding-standard-tester --dev

Usage

  1. Extend Symplify\EasyCodingStandardTester\Testing\AbstractCheckerTestCase class, (*4)

  2. Provide files to doTestFiles() method, (*5)

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;
    }
}

Instead of [__DIR__ . '/wrong/wrong.php.inc', __DIR__ . '/fixed/fixed.php.inc'] you can use single file: __DIR__ . '/fixture/fixture.php.inc' in this format:, (*6)


-----

In pseudo-code:, (*7)

before
------
after


, (*8)

Report Issues

In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker, (*9)

Contribute

The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify., (*10)

The Versions

24/07 2018

dev-master

9999999-dev

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

13/07 2018

v4.5.1

4.5.1.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

30/06 2018

v4.5.0

4.5.0.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

09/06 2018

v4.4.2

4.4.2.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

03/06 2018

v4.4.1

4.4.1.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

03/06 2018

v4.4.0

4.4.0.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

20/05 2018

v4.3.0

4.3.0.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

12/05 2018

v4.2.3

4.2.3.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

12/05 2018

v4.2.1

4.2.1.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

12/05 2018

v4.2.2

4.2.2.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

06/05 2018

v4.2.0

4.2.0.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

24/04 2018

v4.1.0

4.1.0.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

24/04 2018

v4.1.1

4.1.1.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

24/04 2018

v4.1.2

4.1.2.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

07/04 2018

v4.0.2

4.0.2.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

07/04 2018

v4.0.3

4.0.3.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

07/04 2018

v4.0.4

4.0.4.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

01/04 2018

v4.0.0

4.0.0.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

01/04 2018

v4.0.0alpha6

4.0.0.0-alpha6

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

01/04 2018

v4.0.0beta1

4.0.0.0-beta1

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

01/04 2018

v4.0.1

4.0.1.0

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires

 

31/03 2018

v4.0.0alpha5

4.0.0.0-alpha5

# The Best Way to Test Sniffs and Fixers

  Sources   Download

MIT

The Requires