public function testNewIniFunctionChainNotation() { // Setup Test environment $iniObj = new ini(); $iniObj->addSection("foo"); $iniObj->section("foo")->addKey("asdf", "jkl"); $iniObj->section("foo")->addKey("bar", "wee!"); $iniObj->section("foo")->addKey("hi", "hello"); $iniObj->addSection("BAR"); $iniObj->addSection("fOO"); $iniObj->section("fOO")->addKey("yes", "no"); $iniObj->addSection("Hello"); $iniObj->section("Hello")->addKey("world", "true"); $iniObj->addSection("test"); $iniObj->section("test")->addKey("1", "2"); $iniObj->section("test")->addKey("3", "4"); $iniObj->addSection("A Section With Spaces"); $iniObj->section("A Section With Spaces")->addKey("A Key With Spaces", 4); $iniObj->section("A Section With Spaces")->addKey("normalKey", 7); $iniObj->addSection("A.Section.With.Periods"); $iniObj->section("A.Section.With.Periods")->addKey("A.Key.With.Periods", "avalue"); // Test values before save $this->assertEquals("wee!", $iniObj->section("foo")->key("bar")->getValue(), "Wrong foo->bar value"); $this->assertEquals("no", $iniObj->section("fOO")->key("yes")->getValue(), "Wrong fOO->yes value"); $this->assertObjectNotHasAttribute("yes", $iniObj->section("foo"), "This means that case sensitivity doesn't work!"); $this->assertEquals("true", $iniObj->section("Hello")->key("world")->getValue(), "Wrong Hello->world value"); //$this->assertObjectHasAttribute("A__Section__With__Spaces", $iniObj, "Sections with spaces fail"); $this->assertEquals($iniObj->A__Section__With__Spaces, $iniObj->section("A Section With Spaces"), "Sections with spaces fail"); //$this->assertObjectHasAttribute("A__Key__With__Spaces", $iniObj->section("A__Section__With__Spaces"), "Keys with spaces fail"); $this->assertEquals($iniObj->A__Section__With__Spaces->A__Key__With__Spaces, $iniObj->section("A Section With Spaces")->key("A Key With Spaces"), "Keys with spaces fail"); $this->assertEquals(7, $iniObj->section("A Section With Spaces")->key("normalKey")->getValue(), "Wrong A__Section__With__Spaces->normalKey value"); //$this->assertType("int", $iniObj->A__Section__With__Spaces->normalKey->getValue(), "Wrong A__Section__With__Spaces->normalKey Type"); //$this->assertObjectHasAttribute("A__Section__With__Periods", $iniObj, "Sections with periods fail!"); $this->assertEquals($iniObj->A__Section__With__Periods, $iniObj->section("A.Section.With.Periods"), "Sections with Periods fail"); //$this->assertObjectHasAttribute("A__Key__With__Periods", $iniObj->section("A__Section__With__Periods"), "Keys with periods fail!"); $this->assertEquals($iniObj->A__Section__With__Periods->A__Key__With__Periods, $iniObj->section("A.Section.With.Periods")->key("A.Key.With.Periods"), "Keys with Periods fail"); $this->assertEquals("avalue", $iniObj->section("A.Section.With.Periods")->key("A.Key.With.Periods")->getValue(), "Wrong A.Section.With.Periods->A.Key.With.Periods value"); $this->assertNotEquals("aValue", $iniObj->section("A.Section.With.Periods")->key("A.Key.With.Periods")->getValue(), "Values are not case sensitive"); // Save ini file $iniObj->save("unitTest.ini"); unset($iniObj); // Reload ini file from file. $iniObj = new ini("unitTest.ini"); // Test values after fresh load $this->assertEquals("wee!", $iniObj->section("foo")->key("bar")->getValue(), "Redux: Wrong foo->bar value"); $this->assertEquals("no", $iniObj->section("fOO")->key("yes")->getValue(), "Redux: Wrong fOO->yes value"); $this->assertObjectNotHasAttribute("yes", $iniObj->section("foo"), "Redux: This means that case sensitivity doesn't work!"); $this->assertEquals("true", $iniObj->section("Hello")->key("world")->getValue(), "Redux: Wrong Hello->world value"); //$this->assertObjectHasAttribute("A__Section__With__Spaces", $iniObj, "Redux: Sections with spaces fail"); $this->assertEquals($iniObj->A__Section__With__Spaces, $iniObj->section("A Section With Spaces"), "Redux: Sections with spaces fail"); //$this->assertObjectHasAttribute("A__Key__With__Spaces", $iniObj->section("A__Section__With__Spaces"), "Redux: Keys with spaces fail"); $this->assertEquals($iniObj->A__Section__With__Spaces->A__Key__With__Spaces, $iniObj->section("A Section With Spaces")->key("A Key With Spaces"), "Redux: Keys with spaces fail"); $this->assertEquals(7, $iniObj->section("A Section With Spaces")->key("normalKey")->getValue(), "Redux: Wrong A__Section__With__Spaces->normalKey value"); //$this->assertType("int", $iniObj->A__Section__With__Spaces->normalKey->getValue(), "Redux: Wrong A__Section__With__Spaces->normalKey Type"); //$this->assertObjectHasAttribute("A__Section__With__Periods", $iniObj, "Redux: Sections with periods fail!"); $this->assertEquals($iniObj->A__Section__With__Periods, $iniObj->section("A.Section.With.Periods"), "Redux: Sections with Periods fail"); //$this->assertObjectHasAttribute("A__Key__With__Periods", $iniObj->section("A__Section__With__Periods"), "Redux: Keys with periods fail!"); $this->assertEquals($iniObj->A__Section__With__Periods->A__Key__With__Periods, $iniObj->section("A.Section.With.Periods")->key("A.Key.With.Periods"), "Redux: Keys with Periods fail"); $this->assertEquals("avalue", $iniObj->section("A.Section.With.Periods")->key("A.Key.With.Periods")->getValue(), "Redux: Wrong A.Section.With.Periods->A.Key.With.Periods value"); $this->assertNotEquals("aValue", $iniObj->section("A.Section.With.Periods")->key("A.Key.With.Periods")->getValue(), "Redux: Values are not case sensitive"); //Clean up Test Environment. unlink("unitTest.ini"); }