TestCase   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A assertDateTimeEquals() 0 13 1
1
<?php
2
3
namespace JwPersistentUser\Test;
4
5
abstract class TestCase extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * Assert that two dates do not differ more than $treshold seconds.
9
     *
10
     * This is a convenient method to test if dates are propably equal to each other.
11
     *
12
     * @param $expected
13
     * @param $actual
14
     * @param int $threshold
15
     */
16
    protected function assertDateTimeEquals($expected, $actual, $threshold = 10)
17
    {
18
        $this->assertInstanceOf('\DateTime', $expected);
19
        $this->assertInstanceOf('\DateTime', $actual);
20
21
        $diff = abs($expected->getTimestamp() - $actual->getTimestamp());
22
23
        $this->assertLessThan(
24
            $threshold,
25
            $diff,
26
            'Date objects differ too much (' . $diff . ' seconds, treshold is ' . $threshold . ')'
27
        );
28
    }
29
}
30