diff --git a/tests/FlatArrayTest.php b/tests/FlatArrayTest.php index b9c457c..81b42db 100644 --- a/tests/FlatArrayTest.php +++ b/tests/FlatArrayTest.php @@ -95,11 +95,24 @@ class FlatArrayTest extends TestCase $a['foo.bar'] = false; $this->assertFalse($a['foo.bar']); $a['foo.bar'] = 0; - $this->assertEquals(0, $a['foo.bar']); + $this->assertSame(0, $a['foo.bar']); $a['foo.bar'] = ''; - $this->assertEquals('', $a['foo.bar']); + $this->assertSame('', $a['foo.bar']); $a['foo.bar'] = []; - $this->assertEquals([], $a['foo.bar']); + $this->assertSame([], $a['foo.bar']); + } + + public function testMerginFalseyValues() + { + $a = new FlatArray(['foo'=>['bar'=>'baz']]); + $a->merge(['foo'=>['bar'=>false]], null, true); + $this->assertFalse($a['foo.bar']); + $a->merge(['foo'=>['bar'=>0]], null, true); + $this->assertSame(0, $a['foo.bar']); + $a->merge(['foo'=>['bar'=>'']], null, true); + $this->assertSame('', $a['foo.bar']); + $a->merge(['foo'=>['bar'=>[]]], null, true); + $this->assertSame([], $a['foo.bar']); } public function testCaseSensitivity() diff --git a/tests/SelfReferencingFlatArrayTest.php b/tests/SelfReferencingFlatArrayTest.php index 127ce7e..7e3b35c 100644 --- a/tests/SelfReferencingFlatArrayTest.php +++ b/tests/SelfReferencingFlatArrayTest.php @@ -50,4 +50,30 @@ class SelfReferencingFlatArrayTest extends TestCase $this->assertEquals('${foo}', $f['nested.escaped.left']); $this->assertEquals('${foo}', $f['nested.escaped.right']); } + + public function testSettingFalseyValues() + { + $a = new SelfReferencingFlatArray(['foo'=>['bar'=>'baz']]); + $a['foo.bar'] = false; + $this->assertFalse($a['foo.bar']); + $a['foo.bar'] = 0; + $this->assertSame(0, $a['foo.bar']); + $a['foo.bar'] = ''; + $this->assertSame('', $a['foo.bar']); + $a['foo.bar'] = []; + $this->assertSame([], $a['foo.bar']); + } + + public function testMerginFalseyValues() + { + $a = new SelfReferencingFlatArray(['foo'=>['bar'=>'baz']]); + $a->merge(['foo'=>['bar'=>false]], null, true); + $this->assertFalse($a['foo.bar']); + $a->merge(['foo'=>['bar'=>0]], null, true); + $this->assertSame(0, $a['foo.bar']); + $a->merge(['foo'=>['bar'=>'']], null, true); + $this->assertSame('', $a['foo.bar']); + $a->merge(['foo'=>['bar'=>[]]], null, true); + $this->assertSame([], $a['foo.bar']); + } }