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 49 50 51 52 53 54 55 56
|
<?php
namespace Doctrine\Tests\Common\Annotations;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\FileCacheReader;
use Doctrine\Common\Annotations\Reader;
use function glob;
use function method_exists;
use function mkdir;
use function rmdir;
use function sys_get_temp_dir;
use function uniqid;
use function unlink;
class FileCacheReaderTest extends AbstractReaderTest
{
/** @var string */
private $cacheDir;
protected function getReader(): Reader
{
$this->cacheDir = sys_get_temp_dir() . '/annotations_' . uniqid('', true);
@mkdir($this->cacheDir);
return new FileCacheReader(new AnnotationReader(), $this->cacheDir);
}
public function tearDown(): void
{
foreach (glob($this->cacheDir . '/*.php') as $file) {
unlink($file);
}
rmdir($this->cacheDir);
}
/**
* @group DCOM-81
*/
public function testAttemptToCreateAnnotationCacheDir(): void
{
$this->cacheDir = sys_get_temp_dir() . '/not_existed_dir_' . uniqid('', true);
if (method_exists($this, 'assertDirectoryDoesNotExist')) {
self::assertDirectoryDoesNotExist($this->cacheDir);
} else {
self::assertDirectoryNotExists($this->cacheDir);
}
new FileCacheReader(new AnnotationReader(), $this->cacheDir);
self::assertDirectoryExists($this->cacheDir);
}
}
|