responseMock = m::mock('\\Facebook\\FacebookResponse'); } public function testDatesGetCastToDateTime() { $dataFromGraph = [ 'created_time' => '2014-07-15T03:54:34+0000', 'updated_time' => '2014-07-12T01:24:09+0000', 'id' => '123', 'name' => 'Bar', ]; $this->responseMock ->shouldReceive('getDecodedBody') ->once() ->andReturn($dataFromGraph); $factory = new GraphNodeFactory($this->responseMock); $graphNode = $factory->makeGraphAlbum(); $createdTime = $graphNode->getCreatedTime(); $updatedTime = $graphNode->getUpdatedTime(); $this->assertInstanceOf('DateTime', $createdTime); $this->assertInstanceOf('DateTime', $updatedTime); } public function testFromGetsCastAsGraphUser() { $dataFromGraph = [ 'id' => '123', 'from' => [ 'id' => '1337', 'name' => 'Foo McBar', ], ]; $this->responseMock ->shouldReceive('getDecodedBody') ->once() ->andReturn($dataFromGraph); $factory = new GraphNodeFactory($this->responseMock); $graphNode = $factory->makeGraphAlbum(); $from = $graphNode->getFrom(); $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphUser', $from); } public function testPlacePropertyWillGetCastAsGraphPageObject() { $dataFromGraph = [ 'id' => '123', 'name' => 'Foo Album', 'place' => [ 'id' => '1', 'name' => 'For Bar Place', ] ]; $this->responseMock ->shouldReceive('getDecodedBody') ->once() ->andReturn($dataFromGraph); $factory = new GraphNodeFactory($this->responseMock); $graphNode = $factory->makeGraphAlbum(); $place = $graphNode->getPlace(); $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphPage', $place); } }