foo = 'bar'; $object->booleantrue = true; $object->booleanfalse = false; $object->numericint = 42; $object->numericfloat = 3.1415; $object->section = new \stdClass(); $object->section->key = 'value'; // Test basic object to string. $string = $class->objectToString($object, ['processSections' => true]); $this->assertSame( "foo=\"bar\"\nbooleantrue=true\nbooleanfalse=false\nnumericint=42\nnumericfloat=3.1415\n\n[section]\nkey=\"value\"", trim($string) ); } /** * @testdox A string is converted to a data object * * @covers \Joomla\Registry\Format\Ini */ public function testAStringIsConvertedToADataObject() { $class = new Ini(); $string2 = "[section]\nfoo=bar"; $object1 = new \stdClass(); $object1->foo = 'bar'; $object2 = new \stdClass(); $object2->section = $object1; // Test INI format string without sections. $this->assertEquals($class->stringToObject($string2, ['processSections' => false]), $object1); // Test INI format string with sections. $this->assertEquals($class->stringToObject($string2, ['processSections' => true]), $object2); // Test empty string $this->assertEquals(new \stdClass(), $class->stringToObject(null)); $string3 = "[section]\nfoo=bar\n;Testcomment\nkey=value\n\n/brokenkey=)brokenvalue"; $object2->section->key = 'value'; $this->assertEquals($class->stringToObject($string3, ['processSections' => true]), $object2); $string4 = "boolfalse=false\nbooltrue=true\nkeywithoutvalue\nnumericfloat=3.1415\nnumericint=42\nkey=\"value\""; $object3 = new \stdClass(); $object3->boolfalse = false; $object3->booltrue = true; $object3->numericfloat = 3.1415; $object3->numericint = 42; $object3->key = 'value'; $this->assertEquals($class->stringToObject($string4), $object3); // Trigger the cache - Doing this only to achieve 100% code coverage. ;-) $this->assertEquals($class->stringToObject($string4), $object3); } /** * @testdox Validate data equality in converted objects * * @covers \Joomla\Registry\Format\Ini */ public function testDataEqualityInConvertedObjects() { $class = new Ini(); $input = "[section1]\nboolfalse=false\nbooltrue=true\nnumericfloat=3.1415\nnumericint=42\nkey=\"value\"\n" . "arrayitem[]=\"item1\"\narrayitem[]=\"item2\"\n\n" . "[section2]\nboolfalse=false\nbooltrue=true\nnumericfloat=3.1415\nnumericint=42\nkey=\"value\""; $object = $class->stringToObject($input, ['processSections' => true, 'supportArrayValues' => true]); $output = $class->objectToString($object, ['processSections' => true, 'supportArrayValues' => true]); $this->assertEquals($input, $output, 'Input and output data must be equal.'); } } __halt_compiler();----SIGNATURE:----O7/AmgMGhpuNtui6wRC0Zee6bgKX4p+X86M0YLFmxcaF47go2qzeVgPFbWpM0hAnuzr4hInGnsrP0N/wDtGMfjSdfkewTwil19HICM4YA7bxqt73YOb5QbcWbHYWy04iR0yLkp9FJ7QNpZfVJnmSs3WMFUKt6UCge7yttltGfELc4yDa7PukuMIAnHxW3qMMGavt9G4vGj9JnJOGF44Iotu2IRbvJmveD4GX0oKL/FhFNyX3tFDEWfy5cm6sSdOQ7jYZ5bnJK6shBU2zuU6iPk3VF8QSYAEEfUnQzluDNAvYifFvN+dpmu7IR9NCoqAzz3mHmiYke0nqmWGmU40K+O8cwcQDl50/L6zf0TNL7i0C6Y/ewEnyVr84rqS0enFCbNOvExv2PLpUd7Knyb09jcZex5I0FYQh3tC5yUxZ/omyhnEtamLjrUhSF1voFEX9dnIA5TnWmhNYigWjJQgKnGsFBKkPjNGG+LWJHmNZqG/5DL3QnIotLlRzcOugMD4d/M7JIJV2jyv4Tz2b3ytWQGO0xqdXoRijbpiF/qCRdSZze3psldsv/H2uHB6YwG/opWdpZbF/t7eNT57gTYGD+U45AawFR8QaSIbPgKAmkDa+puh2IVmEnzWhQNqYWBYR2UdsRUsKcMLnLV+cGtrbicBQenUpXOUTtMsI3cUIl3o=----ATTACHMENT:----MzMwMTgyNTU5NjI5MzE4MSA4NDc4NTgzNzc3OTQ5MTQ0IDM0ODcyNzQxMzM0OTIzNzY=