@@ 25-34 (lines=10) @@ | ||
22 | $this->assertEquals($params, $cont->getAll()); |
|
23 | } |
|
24 | ||
25 | public function testAdd() |
|
26 | { |
|
27 | $cont = new ImmutableContainer(['foo' => 'a', 'bar' => 'b']); |
|
28 | $result = $cont->add('baz', 'c'); |
|
29 | ||
30 | $this->assertEquals(['foo' => 'a', 'bar' => 'b'], $cont->getAll()); |
|
31 | $this->assertEquals(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $result->getAll()); |
|
32 | $this->assertNotSame($cont, $result); |
|
33 | $this->assertInstanceOf(ImmutableContainer::class, $result); |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * @expectedException \Graze\DataStructure\Exception\RegisteredKeyException |
|
@@ 94-103 (lines=10) @@ | ||
91 | $this->assertFalse($cont->has('foo')); |
|
92 | } |
|
93 | ||
94 | public function testRemove() |
|
95 | { |
|
96 | $cont = new ImmutableContainer(['foo' => 'a', 'bar' => 'b', 'baz' => 'c']); |
|
97 | $result = $cont->remove('bar'); |
|
98 | ||
99 | $this->assertEquals(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $cont->getAll()); |
|
100 | $this->assertEquals(['foo' => 'a', 'baz' => 'c'], $result->getAll()); |
|
101 | $this->assertNotSame($cont, $result); |
|
102 | $this->assertInstanceOf(ImmutableContainer::class, $result); |
|
103 | } |
|
104 | ||
105 | public function testRemoveMissing() |
|
106 | { |
|
@@ 116-125 (lines=10) @@ | ||
113 | $this->assertInstanceOf(ImmutableContainer::class, $result); |
|
114 | } |
|
115 | ||
116 | public function testSet() |
|
117 | { |
|
118 | $cont = new ImmutableContainer(['foo' => 'a', 'bar' => 'b']); |
|
119 | $result = $cont->set('baz', 'c'); |
|
120 | ||
121 | $this->assertEquals(['foo' => 'a', 'bar' => 'b'], $cont->getAll()); |
|
122 | $this->assertEquals(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $result->getAll()); |
|
123 | $this->assertNotSame($cont, $result); |
|
124 | $this->assertInstanceOf(ImmutableContainer::class, $result); |
|
125 | } |
|
126 | ||
127 | public function testSetDuplicate() |
|
128 | { |
@@ 25-34 (lines=10) @@ | ||
22 | $this->assertEquals($params, $cont->getAll()); |
|
23 | } |
|
24 | ||
25 | public function testAdd() |
|
26 | { |
|
27 | $cont = new ImmutableFlatContainer(['foo' => 'a', 'bar' => 'b']); |
|
28 | $result = $cont->add('baz', 'c'); |
|
29 | ||
30 | $this->assertEquals(['foo' => 'a', 'bar' => 'b'], $cont->getAll()); |
|
31 | $this->assertEquals(['foo' => 'a', 'bar' => 'b', 'baz' => 'c'], $result->getAll()); |
|
32 | $this->assertNotSame($cont, $result); |
|
33 | $this->assertInstanceOf(ImmutableFlatContainer::class, $result); |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * @expectedException \Graze\DataStructure\Exception\RegisteredKeyException |