Completed
Push — master ( a8b608...dc5b75 )
by Valentin
02:10
created

ModificationInspectorTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 25
c 0
b 0
f 0
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Cycle\ORM\Promise\Tests;
5
6
use Cycle\ORM\Promise\Materizalizer\ModificationInspector;
7
use Cycle\ORM\Promise\Tests\Fixtures\ModificationInspector\Inspected;
8
use PHPUnit\Framework\TestCase;
9
10
class ModificationInspectorTest extends TestCase
11
{
12
    private function filesDirectory(): string
13
    {
14
        return __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'ModificationInspector';
15
    }
16
17
    public function testDate(): void
18
    {
19
        $lastDate = null;
20
        $files = glob($this->filesDirectory() . DIRECTORY_SEPARATOR . '*');
21
22
        foreach ($files as $file) {
23
            if (is_file($file)) {
24
                $date = new \DateTime('@' . filemtime($file));
25
                if ($date > $lastDate) {
26
                    $lastDate = $date;
27
                }
28
            }
29
        }
30
31
        $inspector = new ModificationInspector();
32
        $this->assertEquals($lastDate, $inspector->getLastModifiedDate(new \ReflectionClass(Inspected::class)));
33
    }
34
}