Skip to content

Commit

Permalink
Use setUp method for cache
Browse files Browse the repository at this point in the history
  • Loading branch information
fire015 committed May 24, 2017
1 parent af0510a commit c2f87e4
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions tests/Cache/ArrayCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,34 @@

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

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

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

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

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

0 comments on commit c2f87e4

Please sign in to comment.