2017-12-28 12:52:29 +08:00
|
|
|
<?php
|
|
|
|
|
2018-08-17 15:25:08 +08:00
|
|
|
namespace Tests;
|
|
|
|
|
2017-12-28 12:52:29 +08:00
|
|
|
use App\Services\Repositories\OptionRepository;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
|
|
|
|
class OptionRepositoryTest extends TestCase
|
|
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
public function testGet()
|
|
|
|
{
|
|
|
|
$repo = new OptionRepository();
|
|
|
|
$repo->set('k1', '(null)');
|
|
|
|
$this->assertNull($repo->get('k1'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSet()
|
|
|
|
{
|
|
|
|
$repo = new OptionRepository();
|
|
|
|
$repo->set([
|
|
|
|
'k1' => 'v1',
|
2019-03-02 22:58:37 +08:00
|
|
|
'k2' => 'v2',
|
2017-12-28 12:52:29 +08:00
|
|
|
]);
|
|
|
|
$this->assertEquals('v1', $repo->get('k1'));
|
|
|
|
$this->assertEquals('v2', $repo->get('k2'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOnly()
|
|
|
|
{
|
|
|
|
$repo = new OptionRepository();
|
|
|
|
$repo->set([
|
|
|
|
'k1' => 'v1',
|
|
|
|
'k2' => 'v2',
|
|
|
|
'k3' => 'v3',
|
|
|
|
]);
|
|
|
|
$this->assertArraySubset([
|
|
|
|
'k1' => 'v1',
|
2019-03-02 22:58:37 +08:00
|
|
|
'k2' => 'v2',
|
2017-12-28 12:52:29 +08:00
|
|
|
], $repo->only(['k1', 'k2']));
|
|
|
|
}
|
|
|
|
}
|