mirror of
https://github.com/flarum/framework.git
synced 2025-03-02 21:30:12 +08:00
Added some tests for the database setting repository
This commit is contained in:
parent
b93d5570d0
commit
a388fe7883
2
framework/core/.gitignore
vendored
2
framework/core/.gitignore
vendored
@ -4,4 +4,4 @@ composer.phar
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
tests/_output/*
|
tests/_output/*
|
||||||
.vagrant
|
.vagrant
|
||||||
.idea/
|
.idea/*
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
"dflydev/fig-cookies": "^1.0",
|
"dflydev/fig-cookies": "^1.0",
|
||||||
"symfony/console": "^2.7",
|
"symfony/console": "^2.7",
|
||||||
"symfony/yaml": "^2.7",
|
"symfony/yaml": "^2.7",
|
||||||
"doctrine/dbal": "^2.5",
|
"doctrine/dbal": "^2.5"
|
||||||
"mockery/mockery": "^0.9.4"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"mockery/mockery": "^0.9.4",
|
||||||
"squizlabs/php_codesniffer": "2.*",
|
"squizlabs/php_codesniffer": "2.*",
|
||||||
"phpunit/phpunit": "^4.8"
|
"phpunit/phpunit": "^4.8"
|
||||||
},
|
},
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
namespace tests\Flarum\Core\Settings;
|
||||||
|
|
||||||
|
use Flarum\Core\Settings\DatabaseSettingsRepository;
|
||||||
|
use Illuminate\Database\ConnectionInterface;
|
||||||
|
use Mockery as m;
|
||||||
|
use tests\Test\TestCase;
|
||||||
|
|
||||||
|
class DatabaseSettingsRepositoryTest extends TestCase
|
||||||
|
{
|
||||||
|
private $connection;
|
||||||
|
private $repository;
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->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'));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user