for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SubjectivePHPTest\Psr\SimpleCache;
use SubjectivePHP\Psr\SimpleCache\TTLValidatorTrait;
/**
* @coversDefaultClass \SubjectivePHP\Psr\SimpleCache\TTLValidatorTrait
*/
final class TTLValidatorTraitTest extends \PHPUnit\Framework\TestCase
{
use TTLValidatorTrait;
* @param mixed $ttl The ttl value which will validate.
*
* @test
* @covers ::validateTTL
* @dataProvider provideValidTTLs
* @return void
public function validateTTLWithValidValues($ttl)
$this->assertNull($this->validateTTL($ttl));
$this->validateTTL($ttl)
SubjectivePHPTest\Psr\Si...raitTest::validateTTL()
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.
}
* Provides valid ttls for testing.
* @return array
public static function provideValidTTLs()
return [
[null],
[\DateInterval::createFromDateString('1 day')],
[3600],
];
* @param mixed $ttl The ttl value which will throw an execption.
* @dataProvider provideInvalidTTLs
public function validateTTLWithInvalidValue($ttl)
$this->expectException(\Psr\SimpleCache\InvalidArgumentException::class);
$this->validateTTL($ttl);
public static function provideInvalidTTLs()
[''],
[1.1],
[new \DateTime()],
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.