Soullivaneuh /
php-cs-fixer-styleci-bridge
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SLLH\StyleCIBridge\Tests; |
||
| 4 | |||
| 5 | use SLLH\StyleCIBridge\ConfigBridge; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @group legacy |
||
| 9 | * We have to add this because of refused PR: https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/2149 |
||
| 10 | * This can be removed while dropping php-cs-fixer 1.x support. |
||
| 11 | * |
||
| 12 | * @author Sullivan Senechal <[email protected]> |
||
| 13 | */ |
||
| 14 | class ConfigBridgeTest extends \PHPUnit_Framework_TestCase |
||
| 15 | { |
||
| 16 | public function testDefaultConfig() |
||
| 17 | { |
||
| 18 | $config = ConfigBridge::create(__DIR__.'/Fixtures/configs/default'); |
||
| 19 | |||
| 20 | if (method_exists($config, 'getRules')) { |
||
| 21 | $this->assertArraySubset(array( |
||
| 22 | 'align_double_arrow' => true, |
||
| 23 | 'long_array_syntax' => true, |
||
| 24 | 'linebreak_after_opening_tag' => true, |
||
| 25 | 'ordered_imports' => true, |
||
| 26 | 'psr0' => false, |
||
| 27 | 'unalign_double_arrow' => false, |
||
| 28 | 'unalign_equals' => false, |
||
| 29 | ), $config->getRules()); |
||
|
0 ignored issues
–
show
|
|||
| 30 | } else { // PHP-CS-Fixer 1.x BC |
||
| 31 | $expectedFixers = array( |
||
| 32 | 'align_double_arrow', |
||
| 33 | 'newline_after_open_tag', |
||
| 34 | 'ordered_use', |
||
| 35 | 'long_array_syntax', |
||
| 36 | 'linebreak_after_opening_tag', |
||
| 37 | '-psr0', |
||
| 38 | '-unalign_double_arrow', |
||
| 39 | '-unalign_equals', |
||
| 40 | ); |
||
| 41 | foreach ($expectedFixers as $expectedFixer) { |
||
| 42 | $this->assertTrue( |
||
| 43 | in_array($expectedFixer, $config->getFixers()), |
||
| 44 | 'The configuration must have the following fixer: "'.$expectedFixer.'".' |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | $this->assertAttributeContains('tmp', 'exclude', $config->getFinder()); |
||
| 50 | $this->assertAttributeContains('autoload.php', 'notNames', $config->getFinder()); |
||
| 51 | } |
||
| 52 | |||
| 53 | public function testNonePreset() |
||
| 54 | { |
||
| 55 | $config = ConfigBridge::create(__DIR__.'/Fixtures/configs/none'); |
||
| 56 | |||
| 57 | if (method_exists($config, 'getRules')) { |
||
| 58 | $this->assertSame(array(), $config->getRules()); |
||
|
0 ignored issues
–
show
The method
getRules() does not seem to exist on object<Symfony\CS\Config>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 59 | } else { // PHP-CS-Fixer 1.x BC |
||
| 60 | $this->assertArraySubset(array(), $config->getFixers()); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 64 | public function testNonePresetWithRules() |
||
| 65 | { |
||
| 66 | $config = ConfigBridge::create(__DIR__.'/Fixtures/configs/none_with_rules'); |
||
| 67 | |||
| 68 | if (method_exists($config, 'getRules')) { |
||
| 69 | $this->assertSame(array( |
||
| 70 | 'align_double_arrow' => true, |
||
| 71 | 'ordered_imports' => true, |
||
| 72 | ), $config->getRules()); |
||
|
0 ignored issues
–
show
The method
getRules() does not seem to exist on object<Symfony\CS\Config>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 73 | } else { // PHP-CS-Fixer 1.x BC |
||
| 74 | $this->assertArraySubset(array( |
||
| 75 | 'align_double_arrow', |
||
| 76 | 'ordered_use', |
||
| 77 | ), $config->getFixers()); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | } |
||
| 81 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.