public function ApcCacheTest::testHas

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Tests/Mapping/Cache/ApcCacheTest.php, line 42

Class

ApcCacheTest

Namespace

Symfony\Component\Validator\Tests\Mapping\Cache

Code

public function testHas() {
  $meta = $this
    ->getMockBuilder('Symfony\\Component\\Validator\\Mapping\\ClassMetadata')
    ->disableOriginalConstructor()
    ->setMethods(array(
    'getClassName',
  ))
    ->getMock();
  $meta
    ->expects($this
    ->once())
    ->method('getClassName')
    ->will($this
    ->returnValue('bar'));
  apc_delete('foobar');
  $cache = new ApcCache('foo');
  $this
    ->assertFalse($cache
    ->has('bar'), '->has() returns false when there is no entry');
  $cache
    ->write($meta);
  $this
    ->assertTrue($cache
    ->has('bar'), '->has() returns true when the is an entry');
}