Issues (75)

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.

tests/Date/IsTest.php (6 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 HMLB\Date\Tests\Date;
4
5
/*
6
 * This file is part of the Date package.
7
 *
8
 * (c) Hugues Maignol <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use HMLB\Date\Date;
15
use HMLB\Date\Tests\AbstractTestCase;
16
17
class IsTest extends AbstractTestCase
18
{
19
    public function testIsWeekdayTrue()
20
    {
21
        $this->assertTrue(Date::createFromDate(2012, 1, 2)->isWeekday());
22
    }
23
24
    public function testIsWeekdayFalse()
25
    {
26
        $this->assertFalse(Date::createFromDate(2012, 1, 1)->isWeekday());
27
    }
28
29
    public function testIsWeekendTrue()
30
    {
31
        $this->assertTrue(Date::createFromDate(2012, 1, 1)->isWeekend());
32
    }
33
34
    public function testIsWeekendFalse()
35
    {
36
        $this->assertFalse(Date::createFromDate(2012, 1, 2)->isWeekend());
37
    }
38
39
    public function testIsYesterdayTrue()
40
    {
41
        $this->assertTrue(Date::now()->subDay()->isYesterday());
42
    }
43
44
    public function testIsYesterdayFalseWithToday()
45
    {
46
        $this->assertFalse(Date::now()->endOfDay()->isYesterday());
47
    }
48
49
    public function testIsYesterdayFalseWith2Days()
50
    {
51
        $this->assertFalse(Date::now()->subDays(2)->startOfDay()->isYesterday());
52
    }
53
54
    public function testIsTodayTrue()
55
    {
56
        $this->assertTrue(Date::now()->isToday());
57
    }
58
59
    public function testIsTodayFalseWithYesterday()
60
    {
61
        $this->assertFalse(Date::now()->subDay()->endOfDay()->isToday());
62
    }
63
64
    public function testIsTodayFalseWithTomorrow()
65
    {
66
        $this->assertFalse(Date::now()->addDay()->startOfDay()->isToday());
67
    }
68
69
    public function testIsTodayWithTimezone()
70
    {
71
        $this->assertTrue(Date::now('Asia/Tokyo')->isToday());
72
    }
73
74
    public function testIsTomorrowTrue()
75
    {
76
        $this->assertTrue(Date::now()->addDay()->isTomorrow());
77
    }
78
79
    public function testIsTomorrowFalseWithToday()
80
    {
81
        $this->assertFalse(Date::now()->endOfDay()->isTomorrow());
82
    }
83
84
    public function testIsTomorrowFalseWith2Days()
85
    {
86
        $this->assertFalse(Date::now()->addDays(2)->startOfDay()->isTomorrow());
87
    }
88
89
    public function testIsFutureTrue()
90
    {
91
        $this->assertTrue(Date::now()->addSecond()->isFuture());
92
    }
93
94
    public function testIsFutureFalse()
95
    {
96
        $this->assertFalse(Date::now()->isFuture());
97
    }
98
99
    public function testIsFutureFalseInThePast()
100
    {
101
        $this->assertFalse(Date::now()->subSecond()->isFuture());
102
    }
103
104
    public function testIsPastTrue()
105
    {
106
        $this->assertTrue(Date::now()->subSecond()->isPast());
107
    }
108
109
    public function testIsPastFalse()
110
    {
111
        $this->assertFalse(Date::now()->addSecond()->isPast());
112
        $this->assertFalse(Date::now()->isPast());
113
    }
114
115
    public function testIsLeapYearTrue()
116
    {
117
        $this->assertTrue(Date::createFromDate(2016, 1, 1)->isLeapYear());
118
    }
119
120
    public function testIsLeapYearFalse()
121
    {
122
        $this->assertFalse(Date::createFromDate(2014, 1, 1)->isLeapYear());
123
    }
124
125
    public function testIsSameDayTrue()
126
    {
127
        $current = Date::createFromDate(2012, 1, 2);
128
        $this->assertTrue($current->isSameDay(Date::createFromDate(2012, 1, 2)));
129
    }
130
131
    public function testIsSameDayFalse()
132
    {
133
        $current = Date::createFromDate(2012, 1, 2);
134
        $this->assertFalse($current->isSameDay(Date::createFromDate(2012, 1, 3)));
135
    }
136
137
    public function testIsSunday()
138
    {
139
        // True in the past past
140
        $this->assertTrue(Date::createFromDate(2015, 5, 31)->isSunday());
141
        $this->assertTrue(Date::createFromDate(2015, 6, 21)->isSunday());
142
        $this->assertTrue(Date::now()->subWeek()->previous(Date::SUNDAY)->isSunday());
143
144
        // True in the future
145
        $this->assertTrue(Date::now()->addWeek()->previous(Date::SUNDAY)->isSunday());
146
        $this->assertTrue(Date::now()->addMonth()->previous(Date::SUNDAY)->isSunday());
147
148
        // False in the past
149
        $this->assertFalse(Date::now()->subWeek()->previous(Date::MONDAY)->isSunday());
150
        $this->assertFalse(Date::now()->subMonth()->previous(Date::MONDAY)->isSunday());
151
152
        // False in the future
153
        $this->assertFalse(Date::now()->addWeek()->previous(Date::MONDAY)->isSunday());
154
        $this->assertFalse(Date::now()->addMonth()->previous(Date::MONDAY)->isSunday());
155
    }
156
157 View Code Duplication
    public function testIsMonday()
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...
158
    {
159
        // True in the past past
160
        $this->assertTrue(Date::createFromDate(2015, 6, 1)->isMonday());
161
        $this->assertTrue(Date::now()->subWeek()->previous(Date::MONDAY)->isMonday());
162
163
        // True in the future
164
        $this->assertTrue(Date::now()->addWeek()->previous(Date::MONDAY)->isMonday());
165
        $this->assertTrue(Date::now()->addMonth()->previous(Date::MONDAY)->isMonday());
166
167
        // False in the past
168
        $this->assertFalse(Date::now()->subWeek()->previous(Date::TUESDAY)->isMonday());
169
        $this->assertFalse(Date::now()->subMonth()->previous(Date::TUESDAY)->isMonday());
170
171
        // False in the future
172
        $this->assertFalse(Date::now()->addWeek()->previous(Date::TUESDAY)->isMonday());
173
        $this->assertFalse(Date::now()->addMonth()->previous(Date::TUESDAY)->isMonday());
174
    }
175
176 View Code Duplication
    public function testIsTuesday()
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...
177
    {
178
        // True in the past past
179
        $this->assertTrue(Date::createFromDate(2015, 6, 2)->isTuesday());
180
        $this->assertTrue(Date::now()->subWeek()->previous(Date::TUESDAY)->isTuesday());
181
182
        // True in the future
183
        $this->assertTrue(Date::now()->addWeek()->previous(Date::TUESDAY)->isTuesday());
184
        $this->assertTrue(Date::now()->addMonth()->previous(Date::TUESDAY)->isTuesday());
185
186
        // False in the past
187
        $this->assertFalse(Date::now()->subWeek()->previous(Date::WEDNESDAY)->isTuesday());
188
        $this->assertFalse(Date::now()->subMonth()->previous(Date::WEDNESDAY)->isTuesday());
189
190
        // False in the future
191
        $this->assertFalse(Date::now()->addWeek()->previous(Date::WEDNESDAY)->isTuesday());
192
        $this->assertFalse(Date::now()->addMonth()->previous(Date::WEDNESDAY)->isTuesday());
193
    }
194
195 View Code Duplication
    public function testIsWednesday()
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...
196
    {
197
        // True in the past past
198
        $this->assertTrue(Date::createFromDate(2015, 6, 3)->isWednesday());
199
        $this->assertTrue(Date::now()->subWeek()->previous(Date::WEDNESDAY)->isWednesday());
200
201
        // True in the future
202
        $this->assertTrue(Date::now()->addWeek()->previous(Date::WEDNESDAY)->isWednesday());
203
        $this->assertTrue(Date::now()->addMonth()->previous(Date::WEDNESDAY)->isWednesday());
204
205
        // False in the past
206
        $this->assertFalse(Date::now()->subWeek()->previous(Date::THURSDAY)->isWednesday());
207
        $this->assertFalse(Date::now()->subMonth()->previous(Date::THURSDAY)->isWednesday());
208
209
        // False in the future
210
        $this->assertFalse(Date::now()->addWeek()->previous(Date::THURSDAY)->isWednesday());
211
        $this->assertFalse(Date::now()->addMonth()->previous(Date::THURSDAY)->isWednesday());
212
    }
213
214 View Code Duplication
    public function testIsThursday()
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...
215
    {
216
        // True in the past past
217
        $this->assertTrue(Date::createFromDate(2015, 6, 4)->isThursday());
218
        $this->assertTrue(Date::now()->subWeek()->previous(Date::THURSDAY)->isThursday());
219
220
        // True in the future
221
        $this->assertTrue(Date::now()->addWeek()->previous(Date::THURSDAY)->isThursday());
222
        $this->assertTrue(Date::now()->addMonth()->previous(Date::THURSDAY)->isThursday());
223
224
        // False in the past
225
        $this->assertFalse(Date::now()->subWeek()->previous(Date::FRIDAY)->isThursday());
226
        $this->assertFalse(Date::now()->subMonth()->previous(Date::FRIDAY)->isThursday());
227
228
        // False in the future
229
        $this->assertFalse(Date::now()->addWeek()->previous(Date::FRIDAY)->isThursday());
230
        $this->assertFalse(Date::now()->addMonth()->previous(Date::FRIDAY)->isThursday());
231
    }
232
233 View Code Duplication
    public function testIsFriday()
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
        // True in the past past
236
        $this->assertTrue(Date::createFromDate(2015, 6, 5)->isFriday());
237
        $this->assertTrue(Date::now()->subWeek()->previous(Date::FRIDAY)->isFriday());
238
239
        // True in the future
240
        $this->assertTrue(Date::now()->addWeek()->previous(Date::FRIDAY)->isFriday());
241
        $this->assertTrue(Date::now()->addMonth()->previous(Date::FRIDAY)->isFriday());
242
243
        // False in the past
244
        $this->assertFalse(Date::now()->subWeek()->previous(Date::SATURDAY)->isFriday());
245
        $this->assertFalse(Date::now()->subMonth()->previous(Date::SATURDAY)->isFriday());
246
247
        // False in the future
248
        $this->assertFalse(Date::now()->addWeek()->previous(Date::SATURDAY)->isFriday());
249
        $this->assertFalse(Date::now()->addMonth()->previous(Date::SATURDAY)->isFriday());
250
    }
251
252 View Code Duplication
    public function testIsSaturday()
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...
253
    {
254
        // True in the past past
255
        $this->assertTrue(Date::createFromDate(2015, 6, 6)->isSaturday());
256
        $this->assertTrue(Date::now()->subWeek()->previous(Date::SATURDAY)->isSaturday());
257
258
        // True in the future
259
        $this->assertTrue(Date::now()->addWeek()->previous(Date::SATURDAY)->isSaturday());
260
        $this->assertTrue(Date::now()->addMonth()->previous(Date::SATURDAY)->isSaturday());
261
262
        // False in the past
263
        $this->assertFalse(Date::now()->subWeek()->previous(Date::SUNDAY)->isSaturday());
264
        $this->assertFalse(Date::now()->subMonth()->previous(Date::SUNDAY)->isSaturday());
265
266
        // False in the future
267
        $this->assertFalse(Date::now()->addWeek()->previous(Date::SUNDAY)->isSaturday());
268
        $this->assertFalse(Date::now()->addMonth()->previous(Date::SUNDAY)->isSaturday());
269
    }
270
}
271