Issues (6)

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/DateTime/Utilities/DateTimeUtilTest.php (1 issue)

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 SubjectivePHPTestDateTime\Utilities;
4
5
use DateTime;
6
use DateTimeZone;
7
use PHPUnit\Framework\TestCase;
8
use SubjectivePHP\DateTime\Utilities\DateTimeUtil;
9
10
/**
11
 * Unit tests for the SubjectivePHP\UtilDateTime class.
12
 *
13
 * @coversDefaultClass \SubjectivePHP\DateTime\Utilities\DateTimeUtil
14
 * @covers ::<private>
15
 */
16 View Code Duplication
final class DateTimeTest extends TestCase
0 ignored issues
show
This class 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...
17
{
18
    /**
19
     * Verify basic behavior of isWeekDay().
20
     *
21
     * @test
22
     * @covers ::isWeekDay
23
     *
24
     * @return void
25
     */
26
    public function isWeekDay()
27
    {
28
        $this->assertTrue(DateTimeUtil::isWeekDay(new DateTime('2014-07-02')));
29
        $this->assertFalse(DateTimeUtil::isWeekDay(new DateTime('2014-07-05')));
30
    }
31
32
    /**
33
     * Verify basic behavior of isWeekendDay().
34
     *
35
     * @test
36
     * @covers ::isWeekendDay
37
     *
38
     * @return void
39
     */
40
    public function isWeekendDay()
41
    {
42
        $this->assertFalse(DateTimeUtil::isWeekendDay(new DateTime('2014-07-02')));
43
        $this->assertTrue(DateTimeUtil::isWeekendDay(new DateTime('2014-07-05')));
44
    }
45
46
    /**
47
     * Verify basic behavior of isSameDay().
48
     *
49
     * @test
50
     * @covers ::isSameDay
51
     *
52
     * @return void
53
     */
54
    public function isSameDay()
55
    {
56
        $thisDate = new DateTime('2015-01-01 12:00:00', new DateTimeZone('Pacific/Fiji'));
57
        $thatDate = new DateTime('2014-12-31 12:00:00', new DateTimeZone('America/New_York'));
58
59
        $this->assertNotEquals($thisDate->format('Y-m-d'), $thatDate->format('Y-m-d'));
60
        $this->assertTrue(DateTimeUtil::isSameDay($thisDate, $thatDate));
61
    }
62
63
    /**
64
     * Verify basic behavior of isDaylightSavings().
65
     *
66
     * @test
67
     * @covers ::isDaylightSavings
68
     *
69
     * @return void
70
     */
71
    public function isDaylightSavings()
72
    {
73
        $dateTime = new DateTime('now', new DateTimeZone('Pacific/Honolulu'));
74
        $this->assertFalse(DateTimeUtil::isDaylightSavings($dateTime));
75
    }
76
77
    /**
78
     * Verify basic behavior of isInRange().
79
     *
80
     * @test
81
     * @covers ::isInRange
82
     *
83
     * @return void
84
     */
85
    public function isInRange()
86
    {
87
        $currentDateTime = new DateTime('now');
88
        $startDateTime = new DateTime('last year');
89
        $endDateTime = new DateTime('next year');
90
        $this->assertTrue(DateTimeUtil::isInRange($currentDateTime, $startDateTime, $endDateTime));
91
    }
92
93
    /**
94
     * Verify error behavior of isInRange().
95
     *
96
     * @test
97
     * @covers ::isInRange
98
     * @expectedException \DomainException
99
     *
100
     * @return void
101
     */
102
    public function isInRangeWithInvalidRange()
103
    {
104
        $currentDateTime = new DateTime('now');
105
        $startDateTime = new DateTime('next year');
106
        $endDateTime = new DateTime('last year');
107
        DateTimeUtil::isInRange($currentDateTime, $startDateTime, $endDateTime);
108
    }
109
110
    /**
111
     * Verify basic behavior of asAgoString().
112
     *
113
     * @test
114
     * @covers ::asAgoString
115
     * @dataProvider provideAgoStringData
116
     *
117
     * @param string $dateTimeString    The date/time string.
118
     * @param string $expectedAgoString The expected ago string.
119
     *
120
     * @return void
121
     */
122
    public function asAgoString(string $dateTimeString, string $expectedAgoString)
123
    {
124
        $this->assertSame($expectedAgoString, DateTimeUtil::asAgoString(new DateTime($dateTimeString)));
125
    }
126
127
    /**
128
     * Returns data for the asAgoString test.
129
     *
130
     * @return array
131
     */
132
    public function provideAgoStringData()
133
    {
134
        return [
135
            [ '-1 minute', 'just now'],
136
            [ '-2 minutes', '2 minutes ago'],
137
            [ '-30 minutes', 'about an hour ago'],
138
            [ '-10 hours', 'about 10 hours ago'],
139
            [ '-25 hours', 'yesterday'],
140
            [ '-3 days', 'about 3 days ago'],
141
            [ '-8 days', 'last week'],
142
            [ '-3 weeks', 'about 3 weeks ago'],
143
            [ '-1 month', 'last month' ],
144
            [ '-2 months', 'about 2 months ago' ],
145
            [ '-12 months', 'last year' ],
146
            [ '-1 year', 'last year' ],
147
            [ '-4 years', 'about 4 years ago' ],
148
        ];
149
    }
150
151
    /**
152
     * Verify error behavior of asAgoString().
153
     *
154
     * @test
155
     * @covers ::asAgoString
156
     * @expectedException \DomainException
157
     *
158
     * @return void
159
     */
160
    public function asAgoStringWithFutureDate()
161
    {
162
        DateTimeUtil::asAgoString(new DateTime('tomorrow'));
163
    }
164
}
165