for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace ArpTest\Entity;
use ArpTest\Entity\Double\DateDeletedAwareFake;
use PHPUnit\Framework\TestCase;
/**
* @covers \Arp\Entity\DateDeletedAwareTrait
* @covers \ArpTest\Entity\Double\DateDeletedAwareFake
*
* @author Alex Patterson <[email protected]>
* @package ArpTest\Entity
*/
final class DateDeletedAwareTraitTest extends TestCase
{
public function testDefaultDateIsNull(): void
$dateDeleted = new DateDeletedAwareFake();
$this->assertNull($dateDeleted->getDateDeleted());
}
public function testHasDateDeletedWillReturnFalseWithNoDeletedDate(): void
$this->assertFalse($dateDeleted->hasDateDeleted());
public function testGetAndSetDateDeleted(): void
$deletedDate = new \DateTime();
$dateDeleted->setDateDeleted($deletedDate);
$this->assertSame($deletedDate, $dateDeleted->getDateDeleted());
$dateDeleted->setDateDeleted(null);
$dateDeleted->getDateDeleted()
ArpTest\Entity\Double\Da...eFake::getDateDeleted()
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.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
This check looks for function or method calls that always return null and whose return value is used.
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.