* * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace Symfony\CS\Tests\Fixer\PSR0; use Symfony\CS\Config\Config; use Symfony\CS\Tests\Fixer\AbstractFixerTestBase; class Psr0FixerTest extends AbstractFixerTestBase { public function testFixCase() { $file = $this->getTestFile(__DIR__.'/../../../Fixer/PSR0/Psr0Fixer.php'); $expected = <<<'EOF' makeTest($expected, $input, $file); $expected = <<<'EOF' makeTest($expected, $input, $file); } public function testFixClassName() { $file = $this->getTestFile(__DIR__.'/../../../Fixer/PSR0/Psr0Fixer.php'); $expected = <<<'EOF' makeTest($expected, $input, $file); } public function testFixAbstractClassName() { $file = $this->getTestFile(__DIR__.'/../../../Fixer/PSR0/Psr0Fixer.php'); $expected = <<<'EOF' makeTest($expected, $input, $file); } public function testFixFinalClassName() { $file = $this->getTestFile(__DIR__.'/../../../Fixer/PSR0/Psr0Fixer.php'); $expected = <<<'EOF' makeTest($expected, $input, $file); } public function testFixClassNameWithComment() { $file = $this->getTestFile(__DIR__.'/../../../Fixer/PSR0/Psr0Fixer.php'); $expected = <<<'EOF' makeTest($expected, $input, $file); } public function testHandlePartialNamespaces() { $fixer = $this->getFixer(); $config = new Config(); $config->setDir(__DIR__.'/../../../'); $fixer->setConfig($config); $file = $this->getTestFile(__DIR__.'/../../../Fixer/PSR0/Psr0Fixer.php'); $expected = <<<'EOF' assertSame($expected, $fixer->fix($file, $input)); $expected = <<<'EOF' assertSame($expected, $fixer->fix($file, $input)); $config->setDir(__DIR__.'/../../../Fixer/PSR0'); $expected = <<<'EOF' assertSame($expected, $fixer->fix($file, $input)); } /** * @dataProvider provideIgnoredCases */ public function testIgnoreWrongNames($filename) { $file = $this->getTestFile($filename); $expected = <<<'EOF' makeTest($expected, null, $file); } public function provideIgnoredCases() { $ignoreCases = array( array('.php'), array('Foo.class.php'), array('4Foo.php'), array('$#.php'), ); foreach (array('__halt_compiler', 'abstract', 'and', 'array', 'as', 'break', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'try', 'unset', 'use', 'var', 'while', 'xor') as $keyword) { $ignoreCases[] = array($keyword.'.php'); } foreach (array('__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__', '__LINE__', '__METHOD__', '__NAMESPACE__') as $magicConstant) { $ignoreCases[] = array($magicConstant.'.php'); $ignoreCases[] = array(strtolower($magicConstant).'.php'); } if (PHP_VERSION_ID >= 50400) { $ignoreCases[] = array('callable.php'); $ignoreCases[] = array('trait.php'); $ignoreCases[] = array('__TRAIT__.php'); $ignoreCases[] = array('insteadof.php'); } if (PHP_VERSION_ID >= 50500) { $ignoreCases[] = array('finally.php'); } return $ignoreCases; } }