DownloadsTraitTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
eloc 10
c 1
b 0
f 1
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_shouldTrackLetter() 0 15 1
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