Test default config
This commit is contained in:
@@ -36,6 +36,15 @@ class ConfigurationTest extends TestCase
|
||||
$this->validateConfig($config);
|
||||
}
|
||||
|
||||
public function testThrowsIfMultipleDirectoriesPassedAndOneNotFound(): void
|
||||
{
|
||||
$config = $this->getValidConfig();
|
||||
$fakeDir = "abc/def/ghi";
|
||||
$config['directories'] = ['./', $fakeDir];
|
||||
$this->expectExceptionMessage("\"abc\/def\/ghi\" is not a directory!");
|
||||
$this->validateConfig($config);
|
||||
}
|
||||
|
||||
public function testThrowsIfNoColoursExist(): void
|
||||
{
|
||||
$config = $this->getValidConfig();
|
||||
@@ -60,14 +69,46 @@ class ConfigurationTest extends TestCase
|
||||
$this->validateConfig($config);
|
||||
}
|
||||
|
||||
private function validateConfig(array $config): void
|
||||
public function testDefaultSizeIs32Pixels(): void
|
||||
{
|
||||
$this->processor->processConfiguration($this->configuration, [$config]);
|
||||
$config = $this->getValidConfig();
|
||||
unset($config['default']['size']);
|
||||
$validatedConfig = $this->validateConfig($config);
|
||||
|
||||
$this->assertSame(32, $validatedConfig['default']['size']);
|
||||
}
|
||||
|
||||
public function testSizeIsSetToProvidedValue(): void
|
||||
{
|
||||
$config = $this->getValidConfig();
|
||||
$config['default']['size'] = 99;
|
||||
$validatedConfig = $this->validateConfig($config);
|
||||
|
||||
$this->assertSame(99, $validatedConfig['default']['size']);
|
||||
}
|
||||
|
||||
public function testDefaultColourIsPrimary(): void
|
||||
{
|
||||
$config = $this->getValidConfig();
|
||||
unset($config['default']['colour']);
|
||||
$validatedConfig = $this->validateConfig($config);
|
||||
|
||||
$this->assertSame('primary', $validatedConfig['default']['colour']);
|
||||
}
|
||||
|
||||
private function validateConfig(array $config): array
|
||||
{
|
||||
return $this->processor->processConfiguration($this->configuration, [$config]);
|
||||
}
|
||||
|
||||
private function getValidConfig(): array
|
||||
{
|
||||
return [
|
||||
'default' => [
|
||||
'colour' => 'primary',
|
||||
'size' => 32
|
||||
],
|
||||
|
||||
'directories' => [
|
||||
'./',
|
||||
],
|
||||
@@ -84,5 +125,4 @@ class ConfigurationTest extends TestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user