Passed
Push — master ( d2520f...3f8ec2 )
by Michael
02:50
created

TestOfHour   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 63
rs 10
c 0
b 0
f 0
wmc 10
lcom 1
cbo 2

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A testPrevDay_Array() 0 10 1
A testGetTimeStamp() 0 4 1
A testPrevMinute() 0 3 1
A testThisSecond() 0 3 1
A testThisMinute() 0 3 1
A testNextSecond() 0 3 1
A setUp() 0 3 1
A testPrevSecond() 0 3 1
A testNextMinute() 0 3 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 12 and the first side effect is on line 135.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
//
3
4
require_once __DIR__ . '/simple_include.php';
5
require_once __DIR__ . '/calendar_include.php';
6
7
require_once __DIR__ . '/./calendar_test.php';
8
9
/**
10
 * Class TestOfHour.
11
 */
12
class TestOfHour extends TestOfCalendar
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
{
14
    /**
15
     * TestOfHour constructor.
16
     */
17
    public function __construct()
18
    {
19
        $this->UnitTestCase('Test of Hour');
20
    }
21
22
    public function setUp()
23
    {
24
        $this->cal = new Calendar_Hour(2003, 10, 25, 13);
25
    }
26
27
    public function testPrevDay_Array()
28
    {
29
        $this->assertEqual([
30
                               'year'   => 2003,
31
                               'month'  => 10,
32
                               'day'    => 24,
33
                               'hour'   => 0,
34
                               'minute' => 0,
35
                               'second' => 0,
36
                           ], $this->cal->prevDay('array'));
37
    }
38
39
    public function testPrevMinute()
40
    {
41
        $this->assertEqual(59, $this->cal->prevMinute());
42
    }
43
44
    public function testThisMinute()
45
    {
46
        $this->assertEqual(0, $this->cal->thisMinute());
47
    }
48
49
    public function testNextMinute()
50
    {
51
        $this->assertEqual(1, $this->cal->nextMinute());
52
    }
53
54
    public function testPrevSecond()
55
    {
56
        $this->assertEqual(59, $this->cal->prevSecond());
57
    }
58
59
    public function testThisSecond()
60
    {
61
        $this->assertEqual(0, $this->cal->thisSecond());
62
    }
63
64
    public function testNextSecond()
65
    {
66
        $this->assertEqual(1, $this->cal->nextSecond());
67
    }
68
69
    public function testGetTimeStamp()
70
    {
71
        $stamp = mktime(13, 0, 0, 10, 25, 2003);
72
        $this->assertEqual($stamp, $this->cal->getTimestamp());
73
    }
74
}
75
76
/**
77
 * Class TestOfHourBuild.
78
 */
79
class TestOfHourBuild extends TestOfHour
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
80
{
81
    /**
82
     * TestOfHourBuild constructor.
83
     */
84
    public function __construct()
85
    {
86
        $this->UnitTestCase('Test of Hour::build()');
87
    }
88
89
    public function testSize()
90
    {
91
        $this->cal->build();
92
        $this->assertEqual(_EXTCAL_TS_MINUTE, $this->cal->size());
93
    }
94
95
    public function testFetch()
96
    {
97
        $this->cal->build();
98
        $i = 0;
99
        while ($Child = $this->cal->fetch()) {
0 ignored issues
show
Unused Code introduced by
The assignment to $Child is dead and can be removed.
Loading history...
100
            ++$i;
101
        }
102
        $this->assertEqual(_EXTCAL_TS_MINUTE, $i);
103
    }
104
105
    public function testFetchAll()
106
    {
107
        $this->cal->build();
108
        $children = [];
109
        $i        = 0;
110
        while ($Child = $this->cal->fetch()) {
111
            $children[$i] = $Child;
112
            ++$i;
113
        }
114
        $this->assertEqual($children, $this->cal->fetchAll());
115
    }
116
117
    public function testSelection()
118
    {
119
        require_once CALENDAR_ROOT . 'Minute.php';
120
        $selection = [new Calendar_Minute(2003, 10, 25, 13, 32)];
121
        $this->cal->build($selection);
122
        $i = 0;
123
        while ($Child = $this->cal->fetch()) {
124
            if (32 == $i) {
125
                break;
126
            }
127
            ++$i;
128
        }
129
        $this->assertTrue($Child->isSelected());
130
    }
131
}
132
133
if (!defined('TEST_RUNNING')) {
134
    define('TEST_RUNNING', true);
135
    $test = new TestOfHour();
136
    $test->run(new HtmlReporter());
0 ignored issues
show
Bug introduced by
The type HtmlReporter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
137
    $test = new TestOfHourBuild();
138
    $test->run(new HtmlReporter());
139
}
140