public function testJsonStructure() { $model = new Google_Model(); $model->publicA = "This is a string"; $model2 = new Google_Model(); $model2->publicC = 12345; $model2->publicD = null; $model->publicB = $model2; $string = json_encode($model->toSimpleObject()); $data = json_decode($string, true); $this->assertEquals(12345, $data['publicB']['publicC']); $this->assertEquals("This is a string", $data['publicA']); $this->assertArrayNotHasKey("publicD", $data['publicB']); $this->assertArrayNotHasKey("data", $data); }
public function testJsonStructure() { $model = new Google_Model(); $model->publicA = "This is a string"; $model2 = new Google_Model(); $model2->publicC = 12345; $model2->publicD = null; $model->publicB = $model2; $model3 = new Google_Model(); $model3->publicE = 54321; $model3->publicF = null; $model->publicG = array($model3, "hello", false); $model->publicH = false; $model->publicI = 0; $string = json_encode($model->toSimpleObject()); $data = json_decode($string, true); $this->assertEquals(12345, $data['publicB']['publicC']); $this->assertEquals("This is a string", $data['publicA']); $this->assertArrayNotHasKey("publicD", $data['publicB']); $this->assertArrayHasKey("publicE", $data['publicG'][0]); $this->assertArrayNotHasKey("publicF", $data['publicG'][0]); $this->assertEquals("hello", $data['publicG'][1]); $this->assertEquals(false, $data['publicG'][2]); $this->assertArrayNotHasKey("data", $data); $this->assertEquals(false, $data['publicH']); $this->assertEquals(0, $data['publicI']); }