You are here

public function FileCacheTest::testFilenameCollision in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FileCacheTest.php \Doctrine\Tests\Common\Cache\FileCacheTest::testFilenameCollision()

File

vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/FileCacheTest.php, line 62

Class

FileCacheTest
@group DCOM-101

Namespace

Doctrine\Tests\Common\Cache

Code

public function testFilenameCollision() {
  $data = array(
    'key:0' => 'key-0',
    'key\\0' => 'key-0',
    'key/0' => 'key-0',
    'key<0' => 'key-0',
    'key>0' => 'key-0',
    'key"0' => 'key-0',
    'key*0' => 'key-0',
    'key?0' => 'key-0',
    'key|0' => 'key-0',
    'key-0' => 'key__0',
    'keyä0' => 'key--0',
  );
  $paths = array();
  $cache = $this->driver;
  $method = new \ReflectionMethod($cache, 'getFilename');
  $method
    ->setAccessible(true);
  foreach ($data as $key => $expected) {
    $path = $method
      ->invoke($cache, $key);
    $actual = pathinfo($path, PATHINFO_FILENAME);
    $this
      ->assertNotContains($path, $paths);
    $this
      ->assertEquals($expected, $actual);
    $paths[] = $path;
  }
}