mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 15:03:44 +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
|
||||
tests/_output/*
|
||||
.vagrant
|
||||
.idea/
|
||||
.idea/*
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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…
Reference in New Issue
Block a user