php-translation /
symfony-bundle
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the PHP Translation package. |
||
| 5 | * |
||
| 6 | * (c) PHP Translation team <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Translation\Bundle\Tests\Unit\Service; |
||
| 13 | |||
| 14 | use PHPUnit\Framework\TestCase; |
||
|
0 ignored issues
–
show
|
|||
| 15 | use Translation\Bundle\Model\Configuration; |
||
| 16 | use Translation\Bundle\Service\ConfigurationManager; |
||
| 17 | use Translation\Bundle\Tests\Unit\Model\ConfigurationTest; |
||
| 18 | |||
| 19 | class ConfigurationManagerTest extends TestCase |
||
| 20 | { |
||
| 21 | public function testGetConfigurationFirst(): void |
||
| 22 | { |
||
| 23 | $manager = new ConfigurationManager(); |
||
| 24 | $correctConfiguration = $this->createConfiguration(['name' => 'correct']); |
||
| 25 | |||
| 26 | $manager->addConfiguration('foo', $correctConfiguration); |
||
| 27 | $manager->addConfiguration('bar', $this->createConfiguration()); |
||
| 28 | |||
| 29 | $this->assertEquals($correctConfiguration, $manager->getConfiguration()); |
||
| 30 | $this->assertEquals($correctConfiguration, $manager->getConfiguration('default')); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function testGetConfigurationDefault(): void |
||
| 34 | { |
||
| 35 | $manager = new ConfigurationManager(); |
||
| 36 | $correctConfiguration = $this->createConfiguration(['name' => 'correct']); |
||
| 37 | |||
| 38 | $manager->addConfiguration('bar', $this->createConfiguration()); |
||
| 39 | $manager->addConfiguration('default', $correctConfiguration); |
||
| 40 | |||
| 41 | $this->assertEquals($correctConfiguration, $manager->getConfiguration()); |
||
| 42 | $this->assertEquals($correctConfiguration, $manager->getConfiguration('default')); |
||
| 43 | $this->assertEquals($correctConfiguration, $manager->getConfiguration('')); |
||
| 44 | $this->assertEquals($correctConfiguration, $manager->getConfiguration(null)); |
||
| 45 | } |
||
| 46 | |||
| 47 | public function testGetConfigurationMissing(): void |
||
| 48 | { |
||
| 49 | $manager = new ConfigurationManager(); |
||
| 50 | $correctConfiguration = $this->createConfiguration(['name' => 'correct']); |
||
| 51 | |||
| 52 | $manager->addConfiguration('bar', $this->createConfiguration()); |
||
| 53 | $manager->addConfiguration('default', $correctConfiguration); |
||
| 54 | |||
| 55 | $this->expectException(\InvalidArgumentException::class); |
||
| 56 | $this->expectExceptionMessage('No configuration found for "missing"'); |
||
| 57 | |||
| 58 | $manager->getConfiguration('missing'); |
||
| 59 | } |
||
| 60 | |||
| 61 | public function testFirstName(): void |
||
| 62 | { |
||
| 63 | $manager = new ConfigurationManager(); |
||
| 64 | $manager->addConfiguration('foo', $this->createConfiguration()); |
||
| 65 | $manager->addConfiguration('bar', $this->createConfiguration()); |
||
| 66 | |||
| 67 | $this->assertEquals('foo', $manager->getFirstName()); |
||
| 68 | } |
||
| 69 | |||
| 70 | public function testFirstNameEmpty(): void |
||
| 71 | { |
||
| 72 | $manager = new ConfigurationManager(); |
||
| 73 | |||
| 74 | $this->assertNull($manager->getFirstName()); |
||
| 75 | } |
||
| 76 | |||
| 77 | public function testGetNames(): void |
||
| 78 | { |
||
| 79 | $manager = new ConfigurationManager(); |
||
| 80 | $manager->addConfiguration('foo', $this->createConfiguration()); |
||
| 81 | $manager->addConfiguration('bar', $this->createConfiguration()); |
||
| 82 | |||
| 83 | $names = $manager->getNames(); |
||
| 84 | $this->assertEquals(['foo', 'bar'], $names); |
||
| 85 | } |
||
| 86 | |||
| 87 | public function testGetNamesEmpty(): void |
||
| 88 | { |
||
| 89 | $manager = new ConfigurationManager(); |
||
| 90 | |||
| 91 | $names = $manager->getNames(); |
||
| 92 | $this->assertEquals([], $names); |
||
| 93 | } |
||
| 94 | |||
| 95 | private function createConfiguration(array $data = []): Configuration |
||
| 96 | { |
||
| 97 | $default = ConfigurationTest::getDefaultData(); |
||
| 98 | |||
| 99 | return new Configuration(\array_merge($default, $data)); |
||
| 100 | } |
||
| 101 | } |
||
| 102 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths