/** * tests compile */ public function test_compileAssociative() { $data = Hip::encode(array('who' => 'let the dogs out', 'theAnswerToLifeTheUniverseAndEverything' => 42)); $this->assertEquals($this->getExpectedHip('associative'), $data); // more layers $data = Hip::encode(array('this' => array('is' => array('pretty' => array('high' => 'doe'))))); $this->assertEquals($this->getExpectedHip('associative3D'), $data); // natives $data = Hip::encode(array('string' => 'string', 'int' => 42, 'float' => 3.14, 'true' => true, 'false' => false, 'null' => null)); $this->assertEquals($this->getExpectedHip('associativeNatives'), $data); }
/** * Get an expected hip data string * * @dataProvider arrayDataProvider */ public function testItAndIfAllWorkImHappy($array) { $hip = Hip::encode($array); // Debugging /*echo "\n"; echo var_dump( $array ); echo "\n"; echo "\n".$hip."\n"; echo "\n"; echo var_dump( Hip::decode( $hip ) ); echo "\n";*/ $this->assertEquals($array, Hip::decode($hip)); }
/** * Test multiple arrays */ public function test_multipleArrays() { // simple array $data = Hip::decode("'foo'\n\tyes\n'foo'\n\tyes\n"); $this->assertEquals(array('foo', array(true), 'foo', array(true)), $data); }