testHasDateDeletedWillReturnFalseWithNoDeletedDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ArpTest\Entity;
6
7
use ArpTest\Entity\Double\DateDeletedAwareFake;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * @covers \Arp\Entity\DateDeletedAwareTrait
12
 * @covers \ArpTest\Entity\Double\DateDeletedAwareFake
13
 *
14
 * @author  Alex Patterson <[email protected]>
15
 * @package ArpTest\Entity
16
 */
17
final class DateDeletedAwareTraitTest extends TestCase
18
{
19
    public function testDefaultDateIsNull(): void
20
    {
21
        $dateDeleted = new DateDeletedAwareFake();
22
23
        $this->assertNull($dateDeleted->getDateDeleted());
24
    }
25
26
    public function testHasDateDeletedWillReturnFalseWithNoDeletedDate(): void
27
    {
28
        $dateDeleted = new DateDeletedAwareFake();
29
30
        $this->assertFalse($dateDeleted->hasDateDeleted());
31
    }
32
33
    public function testGetAndSetDateDeleted(): void
34
    {
35
        $dateDeleted = new DateDeletedAwareFake();
36
37
        $this->assertNull($dateDeleted->getDateDeleted());
38
39
        $deletedDate = new \DateTime();
40
41
        $dateDeleted->setDateDeleted($deletedDate);
42
43
        $this->assertSame($deletedDate, $dateDeleted->getDateDeleted());
44
45
        $dateDeleted->setDateDeleted(null);
46
47
        $this->assertNull($dateDeleted->getDateDeleted());
0 ignored issues
show
Bug introduced by
Are you sure the usage of $dateDeleted->getDateDeleted() targeting ArpTest\Entity\Double\Da...eFake::getDateDeleted() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
48
    }
49
}
50