|
3 | 3 | namespace Tests\Unit\ConfigurationFile;
|
4 | 4 |
|
5 | 5 | use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
|
6 |
| -use Tests\Utils\ConfigurationFileBuilder; |
7 | 6 | use Tests\Utils\{
|
| 7 | + ConfigurationFileBuilder, |
8 | 8 | TestCase\UnitTestCase,
|
9 | 9 | Traits\VirtualFileSystemTrait
|
10 | 10 | };
|
| 11 | +use Wtyd\GitHooks\ConfigurationFile\Exception\ConfigurationFileNotFoundException; |
| 12 | +use Wtyd\GitHooks\ConfigurationFile\Exception\ParseConfigurationFileException; |
11 | 13 | use Wtyd\GitHooks\ConfigurationFile\FileReaderFake;
|
12 | 14 |
|
13 | 15 | /**
|
@@ -90,4 +92,42 @@ function it_searchs_configuration_file_first_in_the_root_directory()
|
90 | 92 |
|
91 | 93 | $this->assertNotEquals($qaFileArray, $fileReaded);
|
92 | 94 | }
|
| 95 | + |
| 96 | + /** |
| 97 | + * @test |
| 98 | + * @expectedException \Wtyd\GitHooks\ConfigurationFile\Exception\ConfigurationFileNotFoundException |
| 99 | + */ |
| 100 | + function it_throws_exception_when_configuration_file_not_found() |
| 101 | + { |
| 102 | + $this->createFileSystem([]); |
| 103 | + $this->expectException(ConfigurationFileNotFoundException::class); |
| 104 | + $this->fileReader->readFile(); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * @test |
| 109 | + * @expectedException \Wtyd\GitHooks\ConfigurationFile\Exception\ParseConfigurationFileException |
| 110 | + */ |
| 111 | + function it_throws_exception_when_yaml_file_is_invalid() |
| 112 | + { |
| 113 | + $invalidYaml = "invalid: yaml: content"; |
| 114 | + $fileSystemStructure = ['githooks.yml' => $invalidYaml]; |
| 115 | + $this->createFileSystem($fileSystemStructure); |
| 116 | + |
| 117 | + $this->expectException(ParseConfigurationFileException::class); |
| 118 | + $this->fileReader->readFile(); |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * @test |
| 123 | + * @expectedException \InvalidArgumentException |
| 124 | + */ |
| 125 | + function it_throws_exception_when_file_type_is_not_supported() |
| 126 | + { |
| 127 | + $fileSystemStructure = ['githooks.txt' => 'unsupported content']; |
| 128 | + $this->createFileSystem($fileSystemStructure); |
| 129 | + |
| 130 | + $this->expectException(ConfigurationFileNotFoundException::class); |
| 131 | + $this->fileReader->readFile(); |
| 132 | + } |
93 | 133 | }
|
0 commit comments