diff --git a/tests/HelperTest.php b/tests/HelperTest.php index cbcf92b..e0d9a19 100644 --- a/tests/HelperTest.php +++ b/tests/HelperTest.php @@ -41,6 +41,35 @@ public function testSet() $this->assertSame(['a' => 'A', 'b' => 'B', 'c' => 'C'], $_SESSION); } + public function testAssocSet() + { + $helper = new Helper(); + + $helper->set('a', ['b' => 'B']); + $this->assertSame(['a' => ['b' => 'B']], $_SESSION); + + $helper->b = ['c' => 'C']; + $this->assertSame(['a' => ['b' => 'B'], 'b' => ['c' => 'C']], $_SESSION); + + $helper['c'] = ['d' => 'D']; + $this->assertSame(['a' => ['b' => 'B'], 'b' => ['c' => 'C'], 'c' => ['d' => 'D']], $_SESSION); + } + + public function testMergeSet() + { + $helper = new Helper(); + $helper->set('a', []); + + $helper->set('a', ['a' => 'A']); + $this->assertSame(['a' => ['a' => 'A']], $_SESSION); + + $helper->a = ['b' => 'B']; + $this->assertSame(['a' => ['a' => 'A', 'b' => 'B']], $_SESSION); + + $helper['a'] = ['c' => 'C']; + $this->assertSame(['a' => ['a' => 'A', 'b' => 'B', 'c' => 'C']], $_SESSION); + } + public function testGet() { $helper = new Helper();