public function testWriteAndRead() { $adapter = new InMemory(); $this->assertFalse($adapter->exists('foobar')); $adapter->write('foobar', 'Some content'); $this->assertTrue($adapter->exists('foobar')); $this->assertEquals('Some content', $adapter->read('foobar')); }
public function testSetFiles() { $adapter = new InMemory(array('foo' => 'Foo content', 'bar' => 'Bar content')); $this->assertFalse($adapter->exists('foobar')); $this->assertTrue($adapter->exists('foo')); $this->assertEquals('Foo content', $adapter->read('foo')); $this->assertTrue($adapter->exists('bar')); $this->assertEquals('Bar content', $adapter->read('bar')); }
/** * @test */ public function shouldNotWriteToFallbackOnFillOnMiss() { $key = "test-file"; $contents = "abc123"; $this->readthroughAdapter = new ReadthroughAdapter($this->primary, $this->fallback, true); $this->fallback->write($key, $contents); $this->readthroughAdapter->read($key); $this->assertTrue($this->primary->exists($key), "primary should not have copy of read file"); $this->assertEquals($contents, $this->primary->read($key), "primary file should match fallback file"); }
public function testWriteFlushAndClose() { $adapter = new Adapter\InMemory(); $stream = new InMemoryBuffer($adapter, 'THE_KEY'); $stream->open(new StreamMode('w')); $this->assertTrue($adapter->exists('THE_KEY')); $this->assertEquals('', $adapter->read('THE_KEY')); $stream->write('foo'); $this->assertEquals('', $adapter->read('THE_KEY')); $stream->flush(); $this->assertEquals('foo', $adapter->read('THE_KEY')); $stream->write('bar'); $stream->close(); $this->assertEquals('foobar', $adapter->read('THE_KEY')); }