1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2016 Facebook, Inc. |
4
|
|
|
* |
5
|
|
|
* You are hereby granted a non-exclusive, worldwide, royalty-free license to |
6
|
|
|
* use, copy, modify, and distribute this software in source code or binary |
7
|
|
|
* form for use in connection with the web services and APIs provided by |
8
|
|
|
* Facebook. |
9
|
|
|
* |
10
|
|
|
* As with any software that integrates with the Facebook platform, your use |
11
|
|
|
* of this software is subject to the Facebook Developer Principles and |
12
|
|
|
* Policies [http://developers.facebook.com/policy/]. This copyright notice |
13
|
|
|
* shall be included in all copies or substantial portions of the software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21
|
|
|
* DEALINGS IN THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
namespace Facebook\Tests\GraphNodes; |
25
|
|
|
|
26
|
|
|
use Mockery as m; |
27
|
|
|
use Facebook\GraphNodes\GraphNodeFactory; |
28
|
|
|
|
29
|
|
|
class GraphAlbumTest extends \PHPUnit_Framework_TestCase |
30
|
|
|
{ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var \Facebook\FacebookResponse |
34
|
|
|
*/ |
35
|
|
|
protected $responseMock; |
36
|
|
|
|
37
|
|
|
protected function setUp() |
38
|
|
|
{ |
39
|
|
|
$this->responseMock = m::mock('\\Facebook\\FacebookResponse'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testDatesGetCastToDateTime() |
43
|
|
|
{ |
44
|
|
|
$dataFromGraph = [ |
45
|
|
|
'created_time' => '2014-07-15T03:54:34+0000', |
46
|
|
|
'updated_time' => '2014-07-12T01:24:09+0000', |
47
|
|
|
'id' => '123', |
48
|
|
|
'name' => 'Bar', |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
$this->responseMock |
|
|
|
|
52
|
|
|
->shouldReceive('getDecodedBody') |
53
|
|
|
->once() |
54
|
|
|
->andReturn($dataFromGraph); |
55
|
|
|
$factory = new GraphNodeFactory($this->responseMock); |
56
|
|
|
$graphNode = $factory->makeGraphAlbum(); |
57
|
|
|
|
58
|
|
|
$createdTime = $graphNode->getCreatedTime(); |
59
|
|
|
$updatedTime = $graphNode->getUpdatedTime(); |
60
|
|
|
|
61
|
|
|
$this->assertInstanceOf('DateTime', $createdTime); |
62
|
|
|
$this->assertInstanceOf('DateTime', $updatedTime); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
View Code Duplication |
public function testFromGetsCastAsGraphUser() |
|
|
|
|
66
|
|
|
{ |
67
|
|
|
$dataFromGraph = [ |
68
|
|
|
'id' => '123', |
69
|
|
|
'from' => [ |
70
|
|
|
'id' => '1337', |
71
|
|
|
'name' => 'Foo McBar', |
72
|
|
|
], |
73
|
|
|
]; |
74
|
|
|
|
75
|
|
|
$this->responseMock |
|
|
|
|
76
|
|
|
->shouldReceive('getDecodedBody') |
77
|
|
|
->once() |
78
|
|
|
->andReturn($dataFromGraph); |
79
|
|
|
$factory = new GraphNodeFactory($this->responseMock); |
80
|
|
|
$graphNode = $factory->makeGraphAlbum(); |
81
|
|
|
|
82
|
|
|
$from = $graphNode->getFrom(); |
83
|
|
|
|
84
|
|
|
$this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphUser', $from); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
View Code Duplication |
public function testPlacePropertyWillGetCastAsGraphPageObject() |
|
|
|
|
88
|
|
|
{ |
89
|
|
|
$dataFromGraph = [ |
90
|
|
|
'id' => '123', |
91
|
|
|
'name' => 'Foo Album', |
92
|
|
|
'place' => [ |
93
|
|
|
'id' => '1', |
94
|
|
|
'name' => 'For Bar Place', |
95
|
|
|
] |
96
|
|
|
]; |
97
|
|
|
|
98
|
|
|
$this->responseMock |
|
|
|
|
99
|
|
|
->shouldReceive('getDecodedBody') |
100
|
|
|
->once() |
101
|
|
|
->andReturn($dataFromGraph); |
102
|
|
|
$factory = new GraphNodeFactory($this->responseMock); |
103
|
|
|
$graphNode = $factory->makeGraphAlbum(); |
104
|
|
|
|
105
|
|
|
$place = $graphNode->getPlace(); |
106
|
|
|
|
107
|
|
|
$this->assertInstanceOf('\\Facebook\\GraphNodes\\GraphPage', $place); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.