Issues (66)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Converter/GithubMilestoneConverterSpec.php (8 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace spec\DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter;
4
5
use DevBoardLib\GithubCore\Repo\GithubRepo;
6
use DevBoardLib\GithubCore\Repo\GithubRepoId;
7
use PhpSpec\ObjectBehavior;
8
use Prophecy\Argument;
9
use tests\DevBoardLib\GithubObjectApiFacade\JsonSampleDataProvider;
10
11
class GithubMilestoneConverterSpec extends ObjectBehavior
12
{
13
    public function it_is_initializable()
14
    {
15
        $this->shouldHaveType('DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter\GithubMilestoneConverter');
16
    }
17
18
    public function let(GithubRepo $githubRepo, GithubRepoId $repoId)
19
    {
20
        $githubRepo->getId()->willReturn($repoId);
21
        $this->beConstructedWith($githubRepo);
22
    }
23
24
    /**
25
     * @dataProvider provideAllMilestones
26
     */
27
    public function it_returns_github_milestone_source_as_result($arrayData)
28
    {
29
        $this->convert($arrayData)
30
            ->shouldReturnAnInstanceOf('DevBoardLib\GithubCore\Milestone\GithubMilestoneSource');
31
    }
32
33
    /**
34
     * @dataProvider provideAllMilestones
35
     */
36
    public function it_will_have_milestone_id_in_converted_result($arrayData)
37
    {
38
        $result = $this->convert($arrayData);
39
40
        $result->getId()->shouldBeAnInstanceOf('DevBoardLib\GithubCore\Milestone\GithubMilestoneId');
41
        $result->getId()->__toString()->shouldBe((string) $arrayData['id']);
42
    }
43
44
    /**
45
     * @dataProvider provideAllMilestones
46
     */
47
    public function it_will_have_repo_id_in_converted_result($arrayData)
48
    {
49
        $result = $this->convert($arrayData);
50
51
        //@TODO: How to test repo & id? (injecting does not work :( )
52
        $result->getRepoId()->shouldBeAnInstanceOf('DevBoardLib\GithubCore\Repo\GithubRepoId');
53
    }
54
55
    /**
56
     * @dataProvider provideAllMilestones
57
     */
58
    public function it_will_have_repo_in_converted_result($arrayData)
59
    {
60
        $result = $this->convert($arrayData);
61
62
        //@TODO: How to test repo & id? (injecting does not work :( )
63
        $result->getRepo()->shouldBeAnInstanceOf('DevBoardLib\GithubCore\Repo\GithubRepo');
64
    }
65
66
    /**
67
     * @dataProvider provideAllMilestones
68
     */
69
    public function it_will_have_milestone_number_in_converted_result($arrayData)
70
    {
71
        $result = $this->convert($arrayData);
72
        $result->getNumber()->shouldBe($arrayData['number']);
73
    }
74
75
    /**
76
     * @dataProvider provideAllMilestones
77
     */
78
    public function it_will_have_milestone_state_in_converted_result($arrayData)
79
    {
80
        $result = $this->convert($arrayData);
81
        $result->getState()->__toString()->shouldBe((string) $arrayData['state']);
82
        $result->getState()->shouldBeAnInstanceOf('DevBoardLib\GithubCore\Milestone\State\GithubMilestoneState');
83
    }
84
85
    /**
86
     * @dataProvider provideOpenMilestones
87
     */
88
    public function it_will_have_open_milestone_state_in_converted_result($arrayData)
89
    {
90
        $result = $this->convert($arrayData);
91
        $result->getState()->__toString()->shouldBe('open');
92
        $result->getState()->shouldBeAnInstanceOf('DevBoardLib\GithubCore\Milestone\State\GithubMilestoneOpenState');
93
    }
94
95
    /**
96
     * @dataProvider provideClosedMilestones
97
     */
98
    public function it_will_have_closed_milestone_state_in_converted_result($arrayData)
99
    {
100
        $result = $this->convert($arrayData);
101
        $result->getState()->__toString()->shouldBe('closed');
102
        $result->getState()->shouldBeAnInstanceOf('DevBoardLib\GithubCore\Milestone\State\GithubMilestoneClosedState');
103
    }
104
105
    /**
106
     * @dataProvider provideAllMilestones
107
     */
108
    public function it_will_have_milestone_title_in_converted_result($arrayData)
109
    {
110
        $result = $this->convert($arrayData);
111
        $result->getTitle()->shouldBe((string) $arrayData['title']);
112
    }
113
114
    /**
115
     * @dataProvider provideAllMilestones
116
     */
117
    public function it_will_have_milestone_description_in_converted_result($arrayData)
118
    {
119
        $result = $this->convert($arrayData);
120
        $result->getDescription()->shouldBe((string) $arrayData['description']);
121
    }
122
123
    /**
124
     * @dataProvider provideMilestonesWithCreator
125
     */
126
    public function it_will_have_user_id_of_creator_in_converted_result($arrayData)
127
    {
128
        $result = $this->convert($arrayData);
129
130
        $result->getCreatedByUserId()
131
            ->shouldBeAnInstanceOf('DevBoardLib\GithubCore\User\GithubUserId');
132
    }
133
134
    /**
135
     * @dataProvider provideMilestonesWithCreator
136
     */
137
    public function it_will_have_creator_in_converted_result($arrayData)
138
    {
139
        $result = $this->convert($arrayData);
140
141
        $result->getCreatedByUser()
142
            ->shouldBeAnInstanceOf('DevBoardLib\GithubCore\User\GithubUserSource');
143
    }
144
145
    /**
146
     * @dataProvider provideMilestonesWithOutCreator
147
     */
148
    public function it_will_have_null_for_user_id_of_creator_in_converted_result($arrayData)
149
    {
150
        $result = $this->convert($arrayData);
151
152
        $result->getCreatedByUserId()->shouldReturn(null);
153
    }
154
155
    /**
156
     * @dataProvider provideMilestonesWithOutCreator
157
     */
158
    public function it_will_have_null_for_creator_in_converted_result($arrayData)
159
    {
160
        $result = $this->convert($arrayData);
161
162
        $result->getCreatedByUser()->shouldReturn(null);
163
    }
164
165
    /**
166
     * @dataProvider provideAllMilestones
167
     */
168
    public function it_will_have_open_issue_count_in_converted_result($arrayData)
169
    {
170
        $result = $this->convert($arrayData);
171
        $result->getOpenIssueCount()->shouldBe($arrayData['open_issues']);
172
    }
173
174
    /**
175
     * @dataProvider provideAllMilestones
176
     */
177
    public function it_will_have_closed_issue_count_in_converted_result($arrayData)
178
    {
179
        $result = $this->convert($arrayData);
180
        $result->getClosedIssueCount()->shouldBe($arrayData['closed_issues']);
181
    }
182
183
    /**
184
     * @dataProvider provideMilestonesWithDueDate
185
     */
186
    public function it_will_have_due_date_in_converted_result($arrayData)
187
    {
188
        $result = $this->convert($arrayData);
189
190
        if (null !== $arrayData['due_on']) {
191
            $result->getDueDate()->shouldBeAnInstanceOf('DateTime');
192
            $result->getDueDate()->format('Y-m-d\TH:i:s\Z')->shouldBe($arrayData['due_on']);
193
        }
194
    }
195
196
    /**
197
     * @dataProvider provideMilestonesWithOutDueDate
198
     */
199
    public function it_will_have_null_if_no_due_date_in_converted_result($arrayData)
200
    {
201
        $result = $this->convert($arrayData);
202
203
        if (null === $arrayData['due_on']) {
204
            $result->getDueDate()->shouldBe(null);
205
        }
206
    }
207
208
    /**
209
     * @dataProvider provideAllMilestones
210
     */
211
    public function it_will_have_github_created_datetime_in_converted_result($arrayData)
212
    {
213
        $result = $this->convert($arrayData);
214
215
        $result->getGithubCreatedAt()->shouldBeAnInstanceOf('DateTime');
216
        $result->getGithubCreatedAt()->format('Y-m-d\TH:i:s\Z')->shouldBe($arrayData['created_at']);
217
    }
218
219
    /**
220
     * @dataProvider provideAllMilestones
221
     */
222 View Code Duplication
    public function it_will_have_github_last_updated_datetime_in_converted_result($arrayData)
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...
223
    {
224
        $result = $this->convert($arrayData);
225
226
        $result->getGithubUpdatedAt()->shouldBeAnInstanceOf('DateTime');
227
        $result->getGithubUpdatedAt()->format('Y-m-d\TH:i:s\Z')->shouldBe($arrayData['updated_at']);
228
    }
229
230
    /**
231
     * @dataProvider provideClosedMilestones
232
     */
233 View Code Duplication
    public function it_will_have_github_closed_datetime_for_closed_milestones_in_converted_result($arrayData)
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...
234
    {
235
        $result = $this->convert($arrayData);
236
237
        $result->getGithubClosedAt()->shouldBeAnInstanceOf('DateTime');
238
        $result->getGithubClosedAt()->format('Y-m-d\TH:i:s\Z')->shouldBe($arrayData['closed_at']);
239
    }
240
241
    /**
242
     * @dataProvider provideOpenMilestones
243
     */
244
    public function it_will_have_null_for_github_closed_datetime_on_open_milestones_in_converted_result($arrayData)
245
    {
246
        $result = $this->convert($arrayData);
247
248
        $result->getGithubClosedAt()->shouldBe(null);
249
    }
250
251
    public function provideAllMilestones()
252
    {
253
        $testData = [];
254
255
        foreach ($this->getDataProvider()->getAllMilestones() as $item) {
256
            $testData[] = [$item];
257
        }
258
259
        return $testData;
260
    }
261
262 View Code Duplication
    public function provideOpenMilestones()
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...
263
    {
264
        $testData = [];
265
266
        foreach ($this->getDataProvider()->getAllMilestones() as $item) {
267
            if ('open' === $item['state']) {
268
                $testData[] = [$item];
269
            }
270
        }
271
272
        return $testData;
273
    }
274
275 View Code Duplication
    public function provideClosedMilestones()
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...
276
    {
277
        $testData = [];
278
279
        foreach ($this->getDataProvider()->getAllMilestones() as $item) {
280
            if ('closed' === $item['state']) {
281
                $testData[] = [$item];
282
            }
283
        }
284
285
        return $testData;
286
    }
287
288 View Code Duplication
    public function provideMilestonesWithDueDate()
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...
289
    {
290
        $testData = [];
291
292
        foreach ($this->getDataProvider()->getAllMilestones() as $item) {
293
            if (null !== $item['due_on']) {
294
                $testData[] = [$item];
295
            }
296
        }
297
298
        return $testData;
299
    }
300
301 View Code Duplication
    public function provideMilestonesWithOutDueDate()
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...
302
    {
303
        $testData = [];
304
305
        foreach ($this->getDataProvider()->getAllMilestones() as $item) {
306
            if (null === $item['due_on']) {
307
                $testData[] = [$item];
308
            }
309
        }
310
311
        return $testData;
312
    }
313
314 View Code Duplication
    public function provideMilestonesWithCreator()
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...
315
    {
316
        $testData = [];
317
318
        foreach ($this->getDataProvider()->getAllMilestones() as $item) {
319
            if (null !== $item['creator']) {
320
                $testData[] = [$item];
321
            }
322
        }
323
324
        return $testData;
325
    }
326
327 View Code Duplication
    public function provideMilestonesWithOutCreator()
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...
328
    {
329
        $testData = [];
330
331
        foreach ($this->getDataProvider()->getAllMilestones('symfony/symfony') as $item) {
332
            if (null === $item['creator']) {
333
                $testData[] = [$item];
334
            }
335
        }
336
337
        return $testData;
338
    }
339
340
    protected function getDataProvider()
341
    {
342
        return new JsonSampleDataProvider();
343
    }
344
}
345