-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/5.3' into 5.3
- Loading branch information
Showing
1 changed file
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
|
||
use Illuminate\Config\Repository; | ||
|
||
class RepositoryTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Illuminate\Config\Repository | ||
*/ | ||
protected $repository; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $config; | ||
|
||
public function setUp() | ||
{ | ||
$this->repository = new Repository($this->config = [ | ||
'foo' => 'bar', | ||
'bar' => 'baz', | ||
'null' => null, | ||
'associate' => [ | ||
'x' => 'xxx', | ||
'y' => 'yyy', | ||
], | ||
'array' => [ | ||
'aaa', | ||
'zzz', | ||
], | ||
]); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testConstruct() | ||
{ | ||
$this->assertInstanceOf(Repository::class, $this->repository); | ||
} | ||
|
||
public function testHasIsTrue() | ||
{ | ||
$this->assertTrue($this->repository->has('foo')); | ||
} | ||
|
||
public function testHasIsTFalse() | ||
{ | ||
$this->assertFalse($this->repository->has('not-exist')); | ||
} | ||
|
||
public function testGet() | ||
{ | ||
$this->assertSame('bar', $this->repository->get('foo')); | ||
} | ||
|
||
public function testGetWithDefault() | ||
{ | ||
$this->assertSame('default', $this->repository->get('not-exist', 'default')); | ||
} | ||
|
||
public function testSet() | ||
{ | ||
$this->repository->set('key', 'value'); | ||
$this->assertSame('value', $this->repository->get('key')); | ||
} | ||
|
||
public function testSetArray() | ||
{ | ||
$this->repository->set([ | ||
'key1' => 'value1', | ||
'key2' => 'value2', | ||
]); | ||
$this->assertSame('value1', $this->repository->get('key1')); | ||
$this->assertSame('value2', $this->repository->get('key2')); | ||
} | ||
|
||
public function testPrepend() | ||
{ | ||
$this->repository->prepend('array', 'xxx'); | ||
$this->assertSame('xxx', $this->repository->get('array.0')); | ||
} | ||
|
||
public function testPush() | ||
{ | ||
$this->repository->push('array', 'xxx'); | ||
$this->assertSame('xxx', $this->repository->get('array.2')); | ||
} | ||
} |