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\KeyValidatorTrait;
/**
* @coversDefaultClass \SubjectivePHP\Psr\SimpleCache\KeyValidatorTrait
* @covers ::<private>
*/
final class KeyValidatorTraitTest extends \PHPUnit\Framework\TestCase
{
use KeyValidatorTrait;
* @test
* @covers ::validateKey
*
* @return void
public function validateKeyWithString()
$this->assertNull($this->validateKey('a valid string'));
}
* @param mixed $key The key value which will throw an execption.
* @expectedException \Psr\SimpleCache\InvalidArgumentException
* @dataProvider provideInvalidKeys
public function validateKeyWithInvalidValue($key)
$this->validateKey($key);
* @covers ::validateKeys
public function validateKeysWithString()
$this->assertNull($this->validateKeys(['a valid string', 'another valid string']));
public function validateKeysWithInvalidValue($key)
$this->validateKeys(['valid_key', $key, 'another_valid_key']);
* Provides valid keys for testing.
* @return array
public function provideInvalidKeys() : array
return [
['an empty string' => ''],
['an object' => new \StdClass()],
['an integer' => 123],
['reserved characters' => '@key'],
];