blob: a3ad5f79ea31bc6f3c0ca3ff98347dfcb6597872 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?php
namespace RssBridge\Tests\Caches;
use CacheInterface;
use PHPUnit\Framework\TestCase;
class CacheImplementationTest extends TestCase
{
private $class;
/**
* @dataProvider dataCachesProvider
*/
public function testClassName($path)
{
$this->setCache($path);
$this->assertTrue($this->class === ucfirst($this->class), 'class name must start with uppercase character');
$this->assertEquals(0, substr_count($this->class, ' '), 'class name must not contain spaces');
$this->assertStringEndsWith('Cache', $this->class, 'class name must end with "Cache"');
}
/**
* @dataProvider dataCachesProvider
*/
public function testClassType($path)
{
$this->setCache($path);
$this->assertTrue(is_subclass_of($this->class, CacheInterface::class), 'class must be subclass of CacheInterface');
}
////////////////////////////////////////////////////////////////////////////
public function dataCachesProvider()
{
$caches = [];
foreach (glob(PATH_LIB_CACHES . '*.php') as $path) {
$caches[basename($path, '.php')] = [$path];
}
return $caches;
}
private function setCache($path)
{
$this->class = '\\' . basename($path, '.php');
$this->assertTrue(class_exists($this->class), 'class ' . $this->class . ' doesn\'t exist');
}
}
|