public function testLocationPropertyWillGetCastAsGraphLocationObject() { $dataFromGraph = ['id' => '123', 'name' => 'Foo Page', 'location' => ['city' => 'Washington', 'country' => 'United States', 'latitude' => 38.881634205431, 'longitude' => -77.029121075722, 'state' => 'DC']]; $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph); $factory = new GraphNodeFactory($this->responseMock); $graphNode = $factory->makeGraphPage(); $location = $graphNode->getLocation(); $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphLocation', $location); }
public function testVenueGetsCastAsGraphLocation() { $dataFromGraph = ['venue' => ['id' => '1337']]; $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph); $factory = new GraphNodeFactory($this->responseMock); $graphNode = $factory->makeGraphGroup(); $venue = $graphNode->getVenue(); $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphLocation', $venue); }
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); }
public function testParentGroupGetsCastAsGraphGroup() { $dataFromGraph = ['parent_group' => ['id' => '1337']]; $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph); $factory = new GraphNodeFactory($this->responseMock); $graphObject = $factory->makeGraphEvent(); $parentGroup = $graphObject->getParentGroup(); $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphGroup', $parentGroup); }
public function testDatesGetCastToDateTime() { $dataFromGraph = ['expires_at' => 123, 'issued_at' => 1337]; $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph); $factory = new GraphNodeFactory($this->responseMock); $graphNode = $factory->makeGraphSessionInfo(); $expires = $graphNode->getExpiresAt(); $issuedAt = $graphNode->getIssuedAt(); $this->assertInstanceOf('DateTime', $expires); $this->assertInstanceOf('DateTime', $issuedAt); }
public function testPicturePropertiesWillGetCastAsGraphPictureObjects() { $dataFromGraph = ['id' => '123', 'name' => 'Foo User', 'picture' => ['is_silhouette' => true, 'url' => 'http://foo.bar', 'width' => 200, 'height' => 200]]; $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($dataFromGraph); $factory = new GraphNodeFactory($this->responseMock); $graphNode = $factory->makeGraphUser(); $Picture = $graphNode->getPicture(); $this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphPicture', $Picture); $this->assertTrue($Picture->isSilhouette()); $this->assertEquals(200, $Picture->getWidth()); $this->assertEquals(200, $Picture->getHeight()); $this->assertEquals('http://foo.bar', $Picture->getUrl()); }
protected function makeFactoryWithData($data) { $this->responseMock->shouldReceive('getDecodedBody')->once()->andReturn($data); return new GraphObjectFactory($this->responseMock); }