public function testArrayProperties() { $backingData = array('id' => 42, 'friends' => array('data' => array(array('id' => 1, 'name' => 'David'), array('id' => 2, 'name' => 'Fosco')), 'paging' => array('next' => 'nexturl'))); $obj = new GraphObject($backingData); $friends = $obj->getPropertyAsArray('friends'); $this->assertEquals(2, count($friends)); $this->assertTrue($friends[0] instanceof GraphObject); $this->assertTrue($friends[1] instanceof GraphObject); $this->assertEquals('David', $friends[0]->getProperty('name')); $this->assertEquals('Fosco', $friends[1]->getProperty('name')); $backingData = array('id' => 42, 'friends' => array(array('id' => 1, 'name' => 'Ilya'), array('id' => 2, 'name' => 'Kevin'))); $obj = new GraphObject($backingData); $friends = $obj->getPropertyAsArray('friends'); $this->assertEquals(2, count($friends)); $this->assertTrue($friends[0] instanceof GraphObject); $this->assertTrue($friends[1] instanceof GraphObject); $this->assertEquals('Ilya', $friends[0]->getProperty('name')); $this->assertEquals('Kevin', $friends[1]->getProperty('name')); }
public function testReturningACollectionAsJasonWillSafelyRepresentDateTimes() { $collection = new GraphObject(['id' => '123', 'date' => new \DateTime('2014-07-15T03:44:53+0000')]); $collectionAsString = $collection->asJson(); $this->assertEquals('{"id":"123","date":"2014-07-15T03:44:53+0000"}', $collectionAsString); }