From 839c96a1045a31280870b754f6bd3774a1356aec Mon Sep 17 00:00:00 2001 From: Bradley Date: Thu, 25 May 2023 14:13:11 +0100 Subject: [PATCH] Test directory validation --- tests/Config/ConfigurationTest.php | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/Config/ConfigurationTest.php diff --git a/tests/Config/ConfigurationTest.php b/tests/Config/ConfigurationTest.php new file mode 100644 index 0000000..2a10df1 --- /dev/null +++ b/tests/Config/ConfigurationTest.php @@ -0,0 +1,67 @@ +configuration = new Configuration(); + $this->processor = new Processor(); + } + + public function testThrowsIfDirectoriesIsEmpty() + { + $config = $this->getValidConfig(); + $config['directories'] = []; + $this->expectExceptionMessage("Directories cannot be empty!"); + $this->validateConfig($config); + } + + public function testThrowsIfDirectoryIsNotFound(): void + { + $config = $this->getValidConfig(); + $fakeDir = "abc/def/ghi"; + $config['directories'] = [$fakeDir]; + $this->expectExceptionMessage("\"abc\/def\/ghi\" is not a directory!"); + $this->validateConfig($config); + } + + + private function validateConfig(array $config): void + { + $this->processor->processConfiguration($this->configuration, [$config]); + } + + private function getValidConfig(): array + { + return [ + 'directories' => [ + './', + ], + + 'palletes' => [ + 'prmary' => [ + 'fill' => 'fill-primary', + 'stroke' => 'stroke-primary', + 'fill-hover' => 'hover:fill-primary', + 'stroke-hover' => 'hover:stroke-primary', + 'fill-group-hover' => 'group-hover:fill-primary', + 'stroke-group-hover' => 'group-hover:stroke-primary', + ], + ], + ]; + } + +}