/** * Test if JSON contains the correct data */ public function testJSON() { $m = new TestModel(); $m->foo = 'bar'; $json = $m->toJSON(); $data = json_decode($json, true); // On model level added public attribute $this->assertArrayHasKey('foo', $data); // On class level declared public attribute $this->assertArrayHasKey('name', $data); // On class level declared private attribute $this->assertArrayNotHasKey('_secret', $data); }