diff --git a/framework/core/.gitignore b/framework/core/.gitignore index 1a43f2275..4cd4e45dd 100644 --- a/framework/core/.gitignore +++ b/framework/core/.gitignore @@ -4,4 +4,4 @@ composer.phar Thumbs.db tests/_output/* .vagrant -.idea/ +.idea/* diff --git a/framework/core/composer.json b/framework/core/composer.json index deeddd58c..44c9c2465 100644 --- a/framework/core/composer.json +++ b/framework/core/composer.json @@ -33,10 +33,10 @@ "dflydev/fig-cookies": "^1.0", "symfony/console": "^2.7", "symfony/yaml": "^2.7", - "doctrine/dbal": "^2.5", - "mockery/mockery": "^0.9.4" + "doctrine/dbal": "^2.5" }, "require-dev": { + "mockery/mockery": "^0.9.4", "squizlabs/php_codesniffer": "2.*", "phpunit/phpunit": "^4.8" }, diff --git a/framework/core/tests/Flarum/Core/Settings/DatabaseSettingsRepositoryTest.php b/framework/core/tests/Flarum/Core/Settings/DatabaseSettingsRepositoryTest.php new file mode 100644 index 000000000..232402206 --- /dev/null +++ b/framework/core/tests/Flarum/Core/Settings/DatabaseSettingsRepositoryTest.php @@ -0,0 +1,33 @@ +connection = m::mock(ConnectionInterface::class); + $this->repository = new DatabaseSettingsRepository($this->connection); + } + + public function test_requesting_an_existing_setting_should_return_its_value() + { + $this->connection->shouldReceive("table->where->pluck")->andReturn('value'); + + $this->assertEquals('value', $this->repository->get('key')); + } + + public function test_non_existent_setting_values_should_return_null() + { + $this->connection->shouldReceive("table->where->pluck")->andReturn(null); + + $this->assertEquals('default', $this->repository->get('key', 'default')); + } +}