<?php

use Flintstone\Cache\ArrayCache;

class ArrayCacheTest extends PHPUnit_Framework_TestCase
{
    public function testGetAndSet()
    {
        $cache = new ArrayCache();
        $cache->set('foo', 'bar');
        $this->assertTrue($cache->contains('foo'));
        $this->assertEquals('bar', $cache->get('foo'));
    }

    public function testDelete()
    {
        $cache = new ArrayCache();
        $cache->set('foo', 'bar');
        $cache->delete('foo');
        $this->assertFalse($cache->contains('foo'));
    }

    public function testFlush()
    {
        $cache = new ArrayCache();
        $cache->set('foo', 'bar');
        $cache->flush();
        $this->assertFalse($cache->contains('foo'));
    }
}

<?php

use Flintstone\Cache\ArrayCache;

class ArrayCacheTest extends PHPUnit_Framework_TestCase
{
    /**
     * @var ArrayCache
     */
    private $cache;

    protected function setUp()
    {
        $this->cache = new ArrayCache();
    }

    public function testGetAndSet()
    {
        $this->cache->set('foo', 'bar');
        $this->assertTrue($this->cache->contains('foo'));
        $this->assertEquals('bar', $this->cache->get('foo'));
    }

    public function testDelete()
    {
        $this->cache->set('foo', 'bar');
        $this->cache->delete('foo');
        $this->assertFalse($this->cache->contains('foo'));
    }

    public function testFlush()
    {
        $this->cache->set('foo', 'bar');
        $this->cache->flush();
        $this->assertFalse($this->cache->contains('foo'));
    }
}

Use setUp method for cache
Use setUp method for cache
