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')); }
public function testOverrideWithList() { $this->app['sources.fileSystem.adapter'] = $adapter = new InMemory(array('src/file-dist' => '<%foo%>')); $this->runCommand(self::COMMAND_NAME, array('--override' => array('foo=[1,2,3]'), 'sourcePath' => 'src/')); $expected = "1\n2\n3"; $this->assertSame($expected, $adapter->read('src/file')); }
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 testOverrideWithList() { $this->app['sources.fileSystem.adapter'] = $adapter = new InMemory(array()); $this->runCommand(self::COMMAND_NAME, array('--override' => array('app.foo=[1,2,3]'), 'sourcePath' => 'src/')); $expected = <<<YAML foo: - 1 - 2 - 3 bar: valueAll YAML; $this->assertSame($expected, $adapter->read('app.yml')); }