|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Tests\Domain; |
| 6 | + |
| 7 | +use NunoMaduro\PhpInsights\Domain\Configuration; |
| 8 | +use NunoMaduro\PhpInsights\Domain\Exceptions\InvalidConfiguration; |
| 9 | +use NunoMaduro\PhpInsights\Domain\LinkFormatter\FileLinkFormatter; |
| 10 | +use NunoMaduro\PhpInsights\Domain\LinkFormatter\NullFileLinkFormatter; |
| 11 | +use PHPUnit\Framework\TestCase; |
| 12 | + |
| 13 | +final class ConfigurationTest extends TestCase |
| 14 | +{ |
| 15 | + public function testPassEmptyArrayReturnDefaultConfiguration(): void |
| 16 | + { |
| 17 | + $configuration = new Configuration([]); |
| 18 | + |
| 19 | + self::assertEquals(getcwd(), $configuration->getDirectory()); |
| 20 | + self::assertEquals('default', $configuration->getPreset()); |
| 21 | + self::assertEquals([], $configuration->getAdd()); |
| 22 | + self::assertEquals([], $configuration->getExcludes()); |
| 23 | + self::assertEquals([], $configuration->getConfig()); |
| 24 | + self::assertEquals([], $configuration->getRemoves()); |
| 25 | + } |
| 26 | + |
| 27 | + public function testWithNullIde(): void |
| 28 | + { |
| 29 | + $config = [ |
| 30 | + 'ide' => null, |
| 31 | + ]; |
| 32 | + |
| 33 | + $configuration = new Configuration($config); |
| 34 | + |
| 35 | + self::assertInstanceOf(NullFileLinkFormatter::class, $configuration->getFileLinkFormatter()); |
| 36 | + } |
| 37 | + |
| 38 | + public function testWithEmptyIde(): void |
| 39 | + { |
| 40 | + $config = [ |
| 41 | + 'ide' => '', |
| 42 | + ]; |
| 43 | + |
| 44 | + $configuration = new Configuration($config); |
| 45 | + |
| 46 | + self::assertInstanceOf(NullFileLinkFormatter::class, $configuration->getFileLinkFormatter()); |
| 47 | + } |
| 48 | + |
| 49 | + public function testWithSelectedIde(): void |
| 50 | + { |
| 51 | + $config = [ |
| 52 | + 'ide' => 'sublime', |
| 53 | + ]; |
| 54 | + |
| 55 | + $configuration = new Configuration($config); |
| 56 | + self::assertInstanceOf(FileLinkFormatter::class, $configuration->getFileLinkFormatter()); |
| 57 | + } |
| 58 | + |
| 59 | + public function testWithUnknowIde(): void |
| 60 | + { |
| 61 | + self::expectException(InvalidConfiguration::class); |
| 62 | + self::expectExceptionMessage('Unknow IDE "notepad++"'); |
| 63 | + |
| 64 | + $config = [ |
| 65 | + 'ide' => 'notepad++', |
| 66 | + ]; |
| 67 | + |
| 68 | + new Configuration($config); |
| 69 | + } |
| 70 | +} |
0 commit comments