Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.3' into 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 17, 2016
2 parents 336a807 + b3dbc42 commit cdcd98b
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions tests/Config/RepositoryTest.php
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'));
}
}

0 comments on commit cdcd98b

Please sign in to comment.