1 | <?php |
||||
2 | /** |
||||
3 | * Copyright 2017 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 | namespace Facebook\Tests\GraphNode; |
||||
24 | |||||
25 | use Facebook\GraphNode\GraphObjectFactory; |
||||
26 | use Facebook\Application; |
||||
27 | use Facebook\Request; |
||||
28 | use Facebook\Response; |
||||
29 | use Facebook\GraphNode\GraphList; |
||||
30 | use Facebook\GraphNode\GraphObject; |
||||
31 | use PHPUnit\Framework\TestCase; |
||||
32 | |||||
33 | /** |
||||
34 | * @todo v6: Remove this test |
||||
35 | */ |
||||
36 | class GraphObjectFactoryTest extends TestCase |
||||
37 | { |
||||
38 | /** |
||||
39 | * @var \Facebook\Request |
||||
40 | */ |
||||
41 | protected $request; |
||||
42 | |||||
43 | View Code Duplication | protected function setUp() |
|||
0 ignored issues
–
show
|
|||||
44 | { |
||||
45 | $app = new Application('123', 'foo_app_secret'); |
||||
46 | $this->request = new Request( |
||||
47 | $app, |
||||
48 | 'foo_token', |
||||
49 | 'GET', |
||||
50 | '/me/photos?keep=me', |
||||
51 | ['foo' => 'bar'], |
||||
52 | 'foo_eTag', |
||||
53 | 'v1337' |
||||
54 | ); |
||||
55 | } |
||||
56 | |||||
57 | View Code Duplication | public function testAGraphNodeWillBeCastAsAGraphNode() |
|||
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||||
58 | { |
||||
59 | $data = json_encode([ |
||||
60 | 'id' => '123', |
||||
61 | 'name' => 'Foo McBar', |
||||
62 | 'link' => 'http://facebook/foo', |
||||
63 | ]); |
||||
64 | $res = new Response($this->request, $data); |
||||
65 | |||||
66 | $factory = new GraphObjectFactory($res); |
||||
0 ignored issues
–
show
The class
Facebook\GraphNode\GraphObjectFactory has been deprecated: 5.0.0 GraphObjectFactory has been renamed to GraphNodeFactory
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
67 | $graphObject = $factory->makeGraphObject(); |
||||
0 ignored issues
–
show
The function
Facebook\GraphNode\Graph...tory::makeGraphObject() has been deprecated: 5.0.0 GraphObjectFactory has been renamed to GraphNodeFactory
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||
68 | $graphData = $graphObject->asArray(); |
||||
69 | |||||
70 | $this->assertInstanceOf(GraphObject::class, $graphObject); |
||||
71 | $this->assertEquals([ |
||||
72 | 'id' => '123', |
||||
73 | 'name' => 'Foo McBar', |
||||
74 | 'link' => 'http://facebook/foo', |
||||
75 | ], $graphData); |
||||
76 | } |
||||
77 | |||||
78 | View Code Duplication | public function testAListFromGraphWillBeCastAsAGraphEdge() |
|||
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||||
79 | { |
||||
80 | $data = json_encode([ |
||||
81 | 'data' => [ |
||||
82 | [ |
||||
83 | 'id' => '123', |
||||
84 | 'name' => 'Foo McBar', |
||||
85 | 'link' => 'http://facebook/foo', |
||||
86 | ], |
||||
87 | [ |
||||
88 | 'id' => '1337', |
||||
89 | 'name' => 'Bar McBaz', |
||||
90 | 'link' => 'http://facebook/bar', |
||||
91 | ], |
||||
92 | ], |
||||
93 | 'paging' => [ |
||||
94 | 'next' => 'http://facebook/next', |
||||
95 | 'previous' => 'http://facebook/prev', |
||||
96 | ], |
||||
97 | ]); |
||||
98 | $res = new Response($this->request, $data); |
||||
99 | |||||
100 | $factory = new GraphObjectFactory($res); |
||||
0 ignored issues
–
show
The class
Facebook\GraphNode\GraphObjectFactory has been deprecated: 5.0.0 GraphObjectFactory has been renamed to GraphNodeFactory
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
101 | $graphList = $factory->makeGraphList(); |
||||
0 ignored issues
–
show
The function
Facebook\GraphNode\Graph...actory::makeGraphList() has been deprecated: 5.0.0 GraphObjectFactory has been renamed to GraphNodeFactory
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
Loading history...
|
|||||
102 | $graphData = $graphList->asArray(); |
||||
103 | |||||
104 | $this->assertInstanceOf(GraphList::class, $graphList); |
||||
105 | $this->assertEquals([ |
||||
106 | 'id' => '123', |
||||
107 | 'name' => 'Foo McBar', |
||||
108 | 'link' => 'http://facebook/foo', |
||||
109 | ], $graphData[0]); |
||||
110 | $this->assertEquals([ |
||||
111 | 'id' => '1337', |
||||
112 | 'name' => 'Bar McBaz', |
||||
113 | 'link' => 'http://facebook/bar', |
||||
114 | ], $graphData[1]); |
||||
115 | } |
||||
116 | } |
||||
117 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.