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/Web 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\Domain\Web\Tests\Units; |
||
13 | |||
14 | use Cubiche\Domain\System\StringLiteral; |
||
15 | use Cubiche\Domain\System\Tests\Units\StringLiteralTests; |
||
16 | use Cubiche\Domain\Web\HostName; |
||
17 | use Cubiche\Domain\Web\Path; |
||
18 | use Cubiche\Domain\Web\Port; |
||
19 | use Cubiche\Domain\Web\Url; |
||
20 | |||
21 | /** |
||
22 | * UrlTests class. |
||
23 | * |
||
24 | * Generated by TestGenerator on 2017-03-15 at 11:36:08. |
||
25 | */ |
||
26 | class UrlTests extends StringLiteralTests |
||
27 | { |
||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | protected function randomNativeValue() |
||
32 | { |
||
33 | return $this->faker->url; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | protected function invalidNativeValue() |
||
40 | { |
||
41 | return 'wrong@url\\'; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | protected function uniqueNativeValue() |
||
48 | { |
||
49 | return $this->faker->unique()->url; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | protected function fromNative($value) |
||
56 | { |
||
57 | return Url::fromNative($value); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Test isEmpty method. |
||
62 | */ |
||
63 | View Code Duplication | public function testIsEmpty() |
|
0 ignored issues
–
show
|
|||
64 | { |
||
65 | $this |
||
66 | ->given($url = Url::fromNative($this->randomNativeValue())) |
||
67 | ->then() |
||
68 | ->boolean($url->isEmpty()) |
||
69 | ->isFalse() |
||
70 | ->exception(function () { |
||
71 | Url::fromNative(''); |
||
72 | })->isInstanceOf(\InvalidArgumentException::class) |
||
73 | ; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Test Host method. |
||
78 | */ |
||
79 | public function testHost() |
||
80 | { |
||
81 | $this |
||
82 | ->given($url = Url::fromNative('http://user:[email protected]:80/bar?querystring#fragmentidentifier')) |
||
83 | ->then() |
||
84 | ->object($url->host()) |
||
85 | ->isEqualTo(HostName::fromNative('foo.com')) |
||
86 | ; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Test FragmentId method. |
||
91 | */ |
||
92 | public function testFragmentId() |
||
93 | { |
||
94 | $this |
||
95 | ->given($url = Url::fromNative('http://user:[email protected]:80/bar?querystring#fragmentidentifier')) |
||
96 | ->then() |
||
97 | ->object($url->fragmentId()) |
||
98 | ->isEqualTo(StringLiteral::fromNative('#fragmentidentifier')) |
||
99 | ; |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Test Password method. |
||
104 | */ |
||
105 | public function testPassword() |
||
106 | { |
||
107 | $this |
||
108 | ->given($url = Url::fromNative('http://user:[email protected]:80/bar?querystring#fragmentidentifier')) |
||
109 | ->then() |
||
110 | ->object($url->password()) |
||
111 | ->isEqualTo(StringLiteral::fromNative('pass')) |
||
112 | ; |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * Test Path method. |
||
117 | */ |
||
118 | public function testPath() |
||
119 | { |
||
120 | $this |
||
121 | ->given($url = Url::fromNative('http://user:[email protected]:80/bar?querystring#fragmentidentifier')) |
||
122 | ->then() |
||
123 | ->object($url->path()) |
||
124 | ->isEqualTo(Path::fromNative('/bar')) |
||
125 | ; |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * Test Port method. |
||
130 | */ |
||
131 | public function testPort() |
||
132 | { |
||
133 | $this |
||
134 | ->given($url = Url::fromNative('http://user:[email protected]:80/bar?querystring#fragmentidentifier')) |
||
135 | ->then() |
||
136 | ->object($url->port()) |
||
137 | ->isEqualTo(Port::fromNative(80)) |
||
138 | ; |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * Test QueryString method. |
||
143 | */ |
||
144 | public function testQueryString() |
||
145 | { |
||
146 | $this |
||
147 | ->given($url = Url::fromNative('http://user:[email protected]:80/bar?querystring#fragmentidentifier')) |
||
148 | ->then() |
||
149 | ->object($url->queryString()) |
||
150 | ->isEqualTo(StringLiteral::fromNative('?querystring')) |
||
151 | ; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * Test Scheme method. |
||
156 | */ |
||
157 | public function testScheme() |
||
158 | { |
||
159 | $this |
||
160 | ->given($url = Url::fromNative('http://user:[email protected]:80/bar?querystring#fragmentidentifier')) |
||
161 | ->then() |
||
162 | ->object($url->scheme()) |
||
163 | ->isEqualTo(StringLiteral::fromNative('http')) |
||
164 | ; |
||
165 | } |
||
166 | |||
167 | /** |
||
168 | * Test User method. |
||
169 | */ |
||
170 | public function testUser() |
||
171 | { |
||
172 | $this |
||
173 | ->given($url = Url::fromNative('http://user:[email protected]:80/bar?querystring#fragmentidentifier')) |
||
174 | ->then() |
||
175 | ->object($url->user()) |
||
176 | ->isEqualTo(StringLiteral::fromNative('user')) |
||
177 | ; |
||
178 | } |
||
179 | } |
||
180 |
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.