3 namespace Tests\Behat\Gherkin\Cache;
5 use Behat\Gherkin\Cache\MemoryCache;
6 use Behat\Gherkin\Node\FeatureNode;
7 use Behat\Gherkin\Node\ScenarioNode;
9 class MemoryCacheTest extends \PHPUnit_Framework_TestCase
13 public function testIsFreshWhenThereIsNoFile()
15 $this->assertFalse($this->cache->isFresh('unexisting', time() + 100));
18 public function testIsFreshOnFreshFile()
20 $feature = new FeatureNode(null, null, array(), null, array(), null, null, null, null);
22 $this->cache->write('some_path', $feature);
24 $this->assertFalse($this->cache->isFresh('some_path', time() + 100));
27 public function testIsFreshOnOutdated()
29 $feature = new FeatureNode(null, null, array(), null, array(), null, null, null, null);
31 $this->cache->write('some_path', $feature);
33 $this->assertTrue($this->cache->isFresh('some_path', time() - 100));
36 public function testCacheAndRead()
38 $scenarios = array(new ScenarioNode('Some scenario', array(), array(), null, null));
39 $feature = new FeatureNode('Some feature', 'some description', array(), null, $scenarios, null, null, null, null);
41 $this->cache->write('some_feature', $feature);
42 $featureRead = $this->cache->read('some_feature');
44 $this->assertEquals($feature, $featureRead);
47 protected function setUp()
49 $this->cache = new MemoryCache();