* * 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\Contrib; use Symfony\CS\Tests\Fixer\AbstractFixerTestBase; /** * @author Matteo Beccati */ class Php4ConstructorFixerTest extends AbstractFixerTestBase { public function testNamespaces() { $expected = <<<'EOF' makeTest($expected); } public function testNamespaces2() { $expected = <<<'EOF' makeTest($expected, $input); } public function testNamespaceGlobal() { $expected = <<<'EOF' makeTest($expected, $input); } public function testPhp5Only() { $expected = <<<'EOF' makeTest($expected); } public function testPhp4Only() { $expected = <<<'EOF' makeTest($expected, $input); } public function testBothTheRightWay1() { $expected = <<<'EOF' __construct(); } public function bar() { var_dump(3); } } EOF; $this->makeTest($expected, $input); } public function testBothTheRightWay2() { $expected = <<<'EOF' __construct($bar); } public function bar() { var_dump(3); } } EOF; $this->makeTest($expected, $input); } public function testBothTheRightWay3() { $expected = <<<'EOF' __construct($bar, $baz); } public function bar() { var_dump(3); } } EOF; $this->makeTest($expected, $input); } public function testBothTheOtherWayAround() { $expected = <<<'EOF' Foo($bar); } /** * PHP-4 Constructor. * * This is the real constructor. It's the one that most likely contains any meaningful info in the docblock. */ private function Foo($bar) { var_dump(1); } function bar() { var_dump(3); } } EOF; $this->makeTest($expected, $input); } public function testPhp4Parent() { $expected = <<<'EOF' makeTest($expected, $input); } public function testPhp4ParentInit() { $expected = <<<'EOF' makeTest($expected, $input); } public function testMixedParent() { $expected = <<<'EOF' makeTest($expected, $input); } public function testMixedParent2() { $expected = <<<'EOF' FooParenT(1); var_dump(9); } function bar() { var_dump(3); } } EOF; $this->makeTest($expected, $input); } public function testParentOther() { $expected = <<<'EOF' FooParent(1); var_dump(9); } function bar() { var_dump(3); } } EOF; $this->makeTest($expected, $input); } public function testParentOther2() { $expected = <<<'EOF' makeTest($expected, $input); } public function testClassWithAnonymous() { $expected = <<<'EOF' bar = function () {}; } } EOF; $input = <<<'EOF' bar = function () {}; } } EOF; $this->makeTest($expected, $input); } public function testClassWithComments() { $expected = <<<'EOF' makeTest($expected, $input); } public function testAlphaBeta() { $expected = <<<'EOF' makeTest($expected); } public function testAlphaBetaTrick1() { $expected = <<<'EOF' __construct() echo 'alpha'; } public function __construct() { echo 'beta'; } } EOF; $this->makeTest($expected); } public function testAlphaBetaTrick2() { $expected = <<<'EOF' Foo() echo 'beta'; } } EOF; $this->makeTest($expected); } public function testAlphaBetaTrick3() { $expected = <<<'EOF' __construct(); } public function __construct() { echo 'beta'; } } EOF; $this->makeTest($expected); } public function testAlphaBetaTrick4WithAnotherClass() { $expected = <<<'EOF' Foo(); // Do something more! echo 'beta'; } } Class Bar { function __construct() { $this->foo = 1; } } EOF; $input = <<<'EOF' Foo(); // Do something more! echo 'beta'; } } Class Bar { function bar() { $this->foo = 1; } } EOF; $this->makeTest($expected, $input); } public function testAbstract() { $expected = <<<'EOF' makeTest($expected); } public function testAbstractTrick() { $expected = <<<'EOF' __construct(); } public function __construct() { $this->baz = 1; } } EOF; $this->makeTest($expected); } public function testParentMultipleClasses() { $expected = <<<'EOF' EOF; $input = <<<'EOF' Parent1(); echo "something"; } } class Class2 extends Parent2 { function __construct($foo) { echo "something"; } } ?> EOF; $this->makeTest($expected, $input); } public function testInfiniteRecursion() { $expected = <<<'EOF' EOF; $input = <<<'EOF' __construct(); echo "something"; } } ?> EOF; $this->makeTest($expected, $input); } }