diff --git a/tests/Config/RepositoryTest.php b/tests/Config/RepositoryTest.php new file mode 100644 index 000000000000..a1c6485c658e --- /dev/null +++ b/tests/Config/RepositoryTest.php @@ -0,0 +1,88 @@ +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')); + } +}