public function testTo() { $Nestr = new Nestr(); // Valid $Nestr->_data($this->data); $this->assertEquals($this->data, $Nestr->_data()); }
public function testUnset() { $Nestr = new Nestr(); $Nestr->_data($this->data); // First level unset($Nestr->foo); $this->assertEquals(false, $Nestr->_has("foo")); // Nestred unset($Nestr->one->two); $this->assertEquals(false, $Nestr->one->_has("two")); // Make sure it only deleted the final level $this->assertEquals(true, $Nestr->_has("one")); $Nestr = new Nestr(); $Nestr->_data($this->data); // Invalid, nestred unset($Nestr->BAD->two); $this->assertEquals(false, $Nestr->BAD->_has("two")); // Invalid, nestred unset($Nestr->one->BAD); $this->assertEquals(false, $Nestr->one->_has("BAD")); // Make sure it only deleted the final level $this->assertEquals(true, $Nestr->_has("one")); // Invalid, first level unset($Nestr->BAD); $this->assertEquals(false, $Nestr->_has("BAD")); }
public function testSerializeNested() { $data = ["foo" => "bar", "one" => ["two" => "three"]]; $Nestr = new Nestr(); // Valid $Nestr->_data($data); // First level $tmp = unserialize(serialize($Nestr))->_data(); // Nestred $this->assertEquals($data, $tmp); }