审查视图

vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/VoidCacheTest.php 1.2 KB
王智 authored
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
<?php

namespace Doctrine\Tests\Common\Cache;

use Doctrine\Common\Cache\VoidCache;

/**
 * @covers \Doctrine\Common\Cache\VoidCache
 */
class VoidCacheTest extends \PHPUnit_Framework_TestCase
{
    public function testShouldAlwaysReturnFalseOnContains()
    {
        $cache = new VoidCache();

        $this->assertFalse($cache->contains('foo'));
        $this->assertFalse($cache->contains('bar'));
    }

    public function testShouldAlwaysReturnFalseOnFetch()
    {
        $cache = new VoidCache();

        $this->assertFalse($cache->fetch('foo'));
        $this->assertFalse($cache->fetch('bar'));
    }

    public function testShouldAlwaysReturnTrueOnSaveButNotStoreAnything()
    {
        $cache = new VoidCache();

        $this->assertTrue($cache->save('foo', 'fooVal'));

        $this->assertFalse($cache->contains('foo'));
        $this->assertFalse($cache->fetch('foo'));
    }

    public function testShouldAlwaysReturnTrueOnDelete()
    {
        $cache = new VoidCache();

        $this->assertTrue($cache->delete('foo'));
    }

    public function testShouldAlwaysReturnNullOnGetStatus()
    {
        $cache = new VoidCache();

        $this->assertNull($cache->getStats());
    }
}