This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 Facebook\GraphNodes\Collection; |
||
27 | |||
28 | class CollectionTest extends \PHPUnit_Framework_TestCase |
||
29 | { |
||
30 | |||
31 | View Code Duplication | public function testAnExistingPropertyCanBeAccessed() |
|
0 ignored issues
–
show
|
|||
32 | { |
||
33 | $graphNode = new Collection(['foo' => 'bar']); |
||
34 | |||
35 | $field = $graphNode->getField('foo'); |
||
36 | $this->assertEquals('bar', $field); |
||
37 | |||
38 | // @todo v6: Remove this assertion |
||
39 | $property = $graphNode->getProperty('foo'); |
||
0 ignored issues
–
show
The method
Facebook\GraphNodes\Collection::getProperty() has been deprecated with message: 5.0.0 getProperty() has been renamed to getField()
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
40 | $this->assertEquals('bar', $property); |
||
41 | } |
||
42 | |||
43 | public function testAMissingPropertyWillReturnNull() |
||
44 | { |
||
45 | $graphNode = new Collection(['foo' => 'bar']); |
||
46 | $field = $graphNode->getField('baz'); |
||
47 | |||
48 | $this->assertNull($field, 'Expected the property to return null.'); |
||
49 | } |
||
50 | |||
51 | View Code Duplication | public function testAMissingPropertyWillReturnTheDefault() |
|
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. ![]() |
|||
52 | { |
||
53 | $graphNode = new Collection(['foo' => 'bar']); |
||
54 | |||
55 | $field = $graphNode->getField('baz', 'faz'); |
||
56 | $this->assertEquals('faz', $field); |
||
57 | |||
58 | // @todo v6: Remove this assertion |
||
59 | $property = $graphNode->getProperty('baz', 'faz'); |
||
0 ignored issues
–
show
The method
Facebook\GraphNodes\Collection::getProperty() has been deprecated with message: 5.0.0 getProperty() has been renamed to getField()
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
60 | $this->assertEquals('faz', $property); |
||
61 | } |
||
62 | |||
63 | public function testFalseDefaultsWillReturnSameType() |
||
64 | { |
||
65 | $graphNode = new Collection(['foo' => 'bar']); |
||
66 | |||
67 | $field = $graphNode->getField('baz', ''); |
||
68 | $this->assertSame('', $field); |
||
69 | |||
70 | $field = $graphNode->getField('baz', 0); |
||
71 | $this->assertSame(0, $field); |
||
72 | |||
73 | $field = $graphNode->getField('baz', false); |
||
74 | $this->assertSame(false, $field); |
||
75 | } |
||
76 | |||
77 | public function testTheKeysFromTheCollectionCanBeReturned() |
||
78 | { |
||
79 | $graphNode = new Collection([ |
||
80 | 'key1' => 'foo', |
||
81 | 'key2' => 'bar', |
||
82 | 'key3' => 'baz', |
||
83 | ]); |
||
84 | |||
85 | $fieldNames = $graphNode->getFieldNames(); |
||
86 | $this->assertEquals(['key1', 'key2', 'key3'], $fieldNames); |
||
87 | |||
88 | // @todo v6: Remove this assertion |
||
89 | $propertyNames = $graphNode->getPropertyNames(); |
||
0 ignored issues
–
show
The method
Facebook\GraphNodes\Collection::getPropertyNames() has been deprecated with message: 5.0.0 getPropertyNames() has been renamed to getFieldNames()
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
90 | $this->assertEquals(['key1', 'key2', 'key3'], $propertyNames); |
||
91 | } |
||
92 | |||
93 | public function testAnArrayCanBeInjectedViaTheConstructor() |
||
94 | { |
||
95 | $collection = new Collection(['foo', 'bar']); |
||
96 | $this->assertEquals(['foo', 'bar'], $collection->asArray()); |
||
97 | } |
||
98 | |||
99 | public function testACollectionCanBeConvertedToProperJson() |
||
100 | { |
||
101 | $collection = new Collection(['foo', 'bar', 123]); |
||
102 | |||
103 | $collectionAsString = $collection->asJson(); |
||
104 | |||
105 | $this->assertEquals('["foo","bar",123]', $collectionAsString); |
||
106 | } |
||
107 | |||
108 | public function testACollectionCanBeCounted() |
||
109 | { |
||
110 | $collection = new Collection(['foo', 'bar', 'baz']); |
||
111 | |||
112 | $collectionCount = count($collection); |
||
113 | |||
114 | $this->assertEquals(3, $collectionCount); |
||
115 | } |
||
116 | |||
117 | public function testACollectionCanBeAccessedAsAnArray() |
||
118 | { |
||
119 | $collection = new Collection(['foo' => 'bar', 'faz' => 'baz']); |
||
120 | |||
121 | $this->assertEquals('bar', $collection['foo']); |
||
122 | $this->assertEquals('baz', $collection['faz']); |
||
123 | } |
||
124 | |||
125 | public function testACollectionCanBeIteratedOver() |
||
126 | { |
||
127 | $collection = new Collection(['foo' => 'bar', 'faz' => 'baz']); |
||
128 | |||
129 | $this->assertInstanceOf('IteratorAggregate', $collection); |
||
130 | |||
131 | $newArray = []; |
||
132 | |||
133 | foreach ($collection as $k => $v) { |
||
134 | $newArray[$k] = $v; |
||
135 | } |
||
136 | |||
137 | $this->assertEquals(['foo' => 'bar', 'faz' => 'baz'], $newArray); |
||
138 | } |
||
139 | } |
||
140 |
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.