‪TYPO3CMS  9.5
InterfaceMethodChangedMatcherTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 use PhpParser\NodeTraverser;
19 use PhpParser\NodeVisitor\NameResolver;
20 use PhpParser\ParserFactory;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪InterfaceMethodChangedMatcherTest extends UnitTestCase
28 {
32  public function ‪hitsFromFixtureAreFound()
33  {
34  ‪$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
35  $fixtureFile = __DIR__ . '/Fixtures/InterfaceMethodChangedMatcherFixture.php';
36  $statements = ‪$parser->parse(file_get_contents($fixtureFile));
37 
38  $traverser = new NodeTraverser();
39  $traverser->addVisitor(new NameResolver());
40 
41  $matcherDefinitions = [
42  'like1' => [
43  'newNumberOfArguments' => 2,
44  'restFiles' => [
45  'Foo-1.rst',
46  ],
47  ],
48  'like2' => [
49  'newNumberOfArguments' => 2,
50  'restFiles' => [
51  'Foo-2.rst',
52  ],
53  ],
54  'like3' => [
55  'newNumberOfArguments' => 2,
56  'restFiles' => [
57  'Foo-3.rst',
58  ],
59  ],
60  'like4' => [
61  'newNumberOfArguments' => 2,
62  'restFiles' => [
63  'Foo-3.rst',
64  ],
65  ],
66  ];
67  $subject = new ‪InterfaceMethodChangedMatcher($matcherDefinitions);
68 
69  $traverser->addVisitor($subject);
70  $traverser->traverse($statements);
71  $expectedHitLineNumbers = [
72  30,
73  33,
74  ];
75  $actualHitLineNumbers = [];
76  foreach ($subject->getMatches() as $match) {
77  $actualHitLineNumbers[] = $match['line'];
78  }
79  $this->assertEquals($expectedHitLineNumbers, $actualHitLineNumbers);
80  }
81 }
‪TYPO3\CMS\Install\Tests\Unit\ExtensionScanner\Php\Matcher\InterfaceMethodChangedMatcherTest\hitsFromFixtureAreFound
‪hitsFromFixtureAreFound()
Definition: InterfaceMethodChangedMatcherTest.php:32
‪$parser
‪$parser
Definition: annotationChecker.php:100
‪TYPO3\CMS\Install\Tests\Unit\ExtensionScanner\Php\Matcher
Definition: AbstractCoreMatcherTest.php:3
‪TYPO3\CMS\Install\Tests\Unit\ExtensionScanner\Php\Matcher\InterfaceMethodChangedMatcherTest
Definition: InterfaceMethodChangedMatcherTest.php:28
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\InterfaceMethodChangedMatcher
Definition: InterfaceMethodChangedMatcher.php:33