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 | /** |
||
4 | * This file is part of the Cubiche/Metadata component. |
||
5 | * |
||
6 | * Copyright (c) Cubiche |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Cubiche\Core\Metadata\Tests\Units; |
||
13 | |||
14 | use Cubiche\Core\Metadata\ClassMetadata; |
||
15 | use Cubiche\Core\Metadata\MethodMetadata; |
||
16 | use Cubiche\Core\Metadata\PropertyMetadata; |
||
17 | use Cubiche\Core\Metadata\Tests\Fixtures\Address; |
||
18 | use Cubiche\Core\Metadata\Tests\Fixtures\User; |
||
19 | |||
20 | /** |
||
21 | * ClassMetadataTests class. |
||
22 | * |
||
23 | * Generated by TestGenerator on 2017-05-16 at 13:17:21. |
||
24 | */ |
||
25 | class ClassMetadataTests extends TestCase |
||
26 | { |
||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | protected function createClassMetadata($className) |
||
31 | { |
||
32 | return new ClassMetadata($className); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Test ClassName method. |
||
37 | */ |
||
38 | public function testClassName() |
||
39 | { |
||
40 | $this |
||
41 | ->given($className = User::class) |
||
42 | ->when($classMetadata = $this->createClassMetadata($className)) |
||
43 | ->then() |
||
44 | ->string($classMetadata->className()) |
||
45 | ->isEqualTo($className) |
||
46 | ; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Test Reflection method. |
||
51 | */ |
||
52 | public function testReflection() |
||
53 | { |
||
54 | $this |
||
55 | ->given($className = User::class) |
||
56 | ->when($classMetadata = $this->createClassMetadata($className)) |
||
57 | ->then() |
||
58 | ->object($classMetadata->reflection()) |
||
59 | ->isInstanceOf(\ReflectionClass::class) |
||
60 | ->string($classMetadata->reflection()->name) |
||
61 | ->isEqualTo($className) |
||
62 | ; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Test methodMetadata methods. |
||
67 | */ |
||
68 | View Code Duplication | public function testMethodMetadata() |
|
0 ignored issues
–
show
|
|||
69 | { |
||
70 | $this |
||
71 | ->given($className = User::class) |
||
72 | ->and($methodMetadata = new MethodMetadata($className, 'username')) |
||
73 | ->when($classMetadata = $this->createClassMetadata($className)) |
||
74 | ->then() |
||
75 | ->array($classMetadata->methodsMetadata()) |
||
76 | ->isEmpty() |
||
77 | ->and() |
||
78 | ->when($classMetadata->addMethodMetadata($methodMetadata)) |
||
79 | ->then() |
||
80 | ->array($classMetadata->methodsMetadata()) |
||
81 | ->hasKey('username') |
||
82 | ->object($classMetadata->methodMetadata('username')) |
||
83 | ->isEqualTo($methodMetadata) |
||
84 | ; |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Test propertyMetadata methods. |
||
89 | */ |
||
90 | View Code Duplication | public function testPropertyMetadata() |
|
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. ![]() |
|||
91 | { |
||
92 | $this |
||
93 | ->given($className = User::class) |
||
94 | ->and($propertyMetadata = new PropertyMetadata($className, 'username')) |
||
95 | ->when($classMetadata = $this->createClassMetadata($className)) |
||
96 | ->then() |
||
97 | ->array($classMetadata->propertiesMetadata()) |
||
98 | ->isEmpty() |
||
99 | ->and() |
||
100 | ->when($classMetadata->addPropertyMetadata($propertyMetadata)) |
||
101 | ->then() |
||
102 | ->array($classMetadata->propertiesMetadata()) |
||
103 | ->hasKey('username') |
||
104 | ->object($classMetadata->propertyMetadata('username')) |
||
105 | ->isEqualTo($propertyMetadata) |
||
106 | ; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Test metadata methods. |
||
111 | */ |
||
112 | View Code Duplication | public function testMetadata() |
|
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. ![]() |
|||
113 | { |
||
114 | $this |
||
115 | ->given($className = User::class) |
||
116 | ->and($classMetadata = $this->createClassMetadata($className)) |
||
117 | ->and($classMetadata->addMetadata('collection', 'some_collection_name')) |
||
118 | ->and($classMetadata->addMetadata('embedded', false)) |
||
119 | ->then() |
||
120 | ->array($classMetadata->metadata()) |
||
121 | ->hasKey('collection') |
||
122 | ->hasKey('embedded') |
||
123 | ->boolean($classMetadata->getMetadata('embedded')) |
||
124 | ->isFalse() |
||
125 | ->string($classMetadata->getMetadata('collection')) |
||
126 | ->isEqualTo('some_collection_name') |
||
127 | ; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * Test merge method. |
||
132 | */ |
||
133 | public function testMerge() |
||
134 | { |
||
135 | $this |
||
136 | ->given($classMetadata = $this->createClassMetadata(User::class)) |
||
137 | ->and($classMetadata->addPropertyMetadata(new PropertyMetadata(User::class, 'email'))) |
||
138 | ->and($classMetadata->addMethodMetadata(new MethodMetadata(User::class, 'username'))) |
||
139 | ->and($classMetadata1 = $this->createClassMetadata(User::class)) |
||
140 | ->and($classMetadata1->addPropertyMetadata(new PropertyMetadata(User::class, 'age'))) |
||
141 | ->and($classMetadata1->addMethodMetadata(new MethodMetadata(User::class, 'addresses'))) |
||
142 | ->and($classMetadata1->addMetadata('collection', 'some_collection_name')) |
||
143 | ->then() |
||
144 | ->array($classMetadata->propertiesMetadata()) |
||
145 | ->hasSize(1) |
||
146 | ->notHasKey('age') |
||
147 | ->array($classMetadata->methodsMetadata()) |
||
148 | ->hasSize(1) |
||
149 | ->notHasKey('addresses') |
||
150 | ->array($classMetadata->metadata()) |
||
151 | ->notHasKey('collection') |
||
152 | ->and() |
||
153 | ->when($classMetadata->merge($classMetadata1)) |
||
154 | ->then() |
||
155 | ->array($classMetadata->propertiesMetadata()) |
||
156 | ->hasSize(2) |
||
157 | ->hasKey('age') |
||
158 | ->array($classMetadata->methodsMetadata()) |
||
159 | ->hasSize(2) |
||
160 | ->hasKey('addresses') |
||
161 | ->string($classMetadata->getMetadata('collection')) |
||
162 | ->isEqualTo('some_collection_name') |
||
163 | ; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * Test Serialize/Unserialize method. |
||
168 | */ |
||
169 | public function testSerialize() |
||
170 | { |
||
171 | $this |
||
172 | ->given($classMetadata = $this->createClassMetadata(User::class)) |
||
173 | ->and($classMetadata->addMethodMetadata(new MethodMetadata(User::class, 'username'))) |
||
174 | ->and($classMetadata->addMethodMetadata(new MethodMetadata(User::class, 'email'))) |
||
175 | ->and($classMetadata1 = $this->createClassMetadata(Address::class)) |
||
176 | ->and($classMetadata1->addMethodMetadata(new MethodMetadata(Address::class, 'city'))) |
||
177 | ->when($classMetadata->unserialize($classMetadata1->serialize())) |
||
178 | ->then() |
||
179 | ->string($classMetadata->className()) |
||
180 | ->isEqualTo(Address::class) |
||
181 | ->array($classMetadata->methodsMetadata()) |
||
182 | ->hasKey('city') |
||
183 | ; |
||
184 | } |
||
185 | } |
||
186 |
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.