DownloadsTraitTest::test_shouldTrackLetter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 15
rs 9.9666
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ByTIC\DocumentGenerator\Tests\PdfLetters\Models\Downloads;
4
5
use ByTIC\DocumentGenerator\Tests\AbstractTest;
6
use ByTIC\DocumentGenerator\Tests\Fixtures\Models\Downloads\Downloads;
7
use ByTIC\DocumentGenerator\Tests\Fixtures\Models\PdfLetters\PdfLetter;
8
use DateInterval;
9
10
/**
11
 * Class DownloadsTraitTest
12
 * @package ByTIC\DocumentGenerator\Tests\Models\Downloads
13
 */
14
class DownloadsTraitTest extends AbstractTest
15
{
16
    public function test_shouldTrackLetter()
17
    {
18
        $letter = new PdfLetter();
19
20
        $letter->issueDate = (new \DateTime())->add(new DateInterval('P10D'));
0 ignored issues
show
Bug Best Practice introduced by
The property issueDate does not exist on ByTIC\DocumentGenerator\...ls\PdfLetters\PdfLetter. Since you implemented __set, consider adding a @property annotation.
Loading history...
21
        self::assertTrue(Downloads::instance()->shouldTrackLetter($letter));
22
23
        $letter->issueDate = (new \DateTime())->sub(new DateInterval('P10D'));
24
        self::assertTrue(Downloads::instance()->shouldTrackLetter($letter));
25
26
        $letter->issueDate = (new \DateTime())->sub(new DateInterval('P30D'));
27
        self::assertTrue(Downloads::instance()->shouldTrackLetter($letter));
28
29
        $letter->issueDate = (new \DateTime())->sub(new DateInterval('P61D'));
30
        self::assertFalse(Downloads::instance()->shouldTrackLetter($letter));
31
    }
32
}
33