/** * @covers Symfony\CS\Fixer::fix * @covers Symfony\CS\Fixer::fixFile */ public function testThatFixInvalidFileReportsToErrorManager() { $fixer = new Fixer(); $fixer->setLinter(new Linter()); $config = Config::create()->finder(new \DirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'FixerTest' . DIRECTORY_SEPARATOR . 'invalid'))->fixers(array(new \Symfony\CS\Fixer\PSR2\VisibilityFixer(), new \Symfony\CS\Fixer\Symfony\UnusedUseFixer()))->setUsingCache(false); $changed = $fixer->fix($config, true, true); $pathToInvalidFile = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'FixerTest' . DIRECTORY_SEPARATOR . 'invalid' . DIRECTORY_SEPARATOR . 'somefile.php'; $this->assertCount(0, $changed); $errors = $fixer->getErrorsManager()->getInvalidErrors(); $this->assertCount(1, $errors); $error = $errors[0]; $this->assertInstanceOf('Symfony\\CS\\Error\\Error', $error); $this->assertSame(Error::TYPE_INVALID, $error->getType()); $this->assertSame($pathToInvalidFile, $error->getFilePath()); }
public function __construct() { @trigger_error(sprintf('The "%s" class is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "%s" instead.', __CLASS__, 'Symfony\\CS\\Config'), E_USER_DEPRECATED); parent::__construct(); }
public function testHandlePartialNamespaces() { $fixer = $this->getFixer(); $config = new Config(); $config->setDir(__DIR__ . '/../../../src/'); $fixer->setConfig($config); $file = $this->getTestFile(__DIR__ . '/../../../src/Fixer/Contrib/Psr0Fixer.php'); $expected = <<<'EOF' <?php namespace Foo\Bar\Baz\Fixer\Contrib; class Psr0Fixer {} EOF; $input = <<<'EOF' <?php namespace Foo\Bar\Baz\FIXER\Contrib; class Psr0Fixer {} EOF; $this->doTest($expected, $input, $file, $fixer); $expected = <<<'EOF' <?php namespace /* hi there */ Foo\Bar\Baz\Fixer\Contrib; class /* hi there */ Psr0Fixer {} EOF; $input = <<<'EOF' <?php namespace /* hi there */ Foo\Bar\Baz\FIXER\Contrib; class /* hi there */ Psr0Fixer {} EOF; $this->doTest($expected, $input, $file, $fixer); $config->setDir(__DIR__ . '/../../../src/Fixer/Contrib'); $expected = <<<'EOF' <?php namespace Foo\Bar\Baz; class Psr0Fixer {} EOF; $this->doTest($expected, null, $file, $fixer); }
/** * @dataProvider provideAddCustomFixersCases */ public function testAddCustomFixers($expected, $suite) { $config = Config::create(); $config->addCustomFixers($suite); $this->assertSame($expected, $config->getCustomFixers()); }