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 testLastModifiedTimeIsUpdatedOnWrite() { $adapter = new InMemory(array('foobar' => array('content' => 'Some content', 'mtime' => 123456789))); $time = time(); $adapter->write('foobar', 'Changed content'); $this->assertTrue(in_array($adapter->mtime('foobar'), array($time, $time + 1))); }
/** * @dataProvider providerTestContainer */ public function testContainer($service, $expected) { $adapter = new InMemory(); $adapter->write(Application::DEFAULT_MASTER_FILE, null); $app = new Application(); $app['configuration.fileSystem.adapter'] = $adapter; $this->assertInstanceOf($expected, $app[$service]); }
/** * @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"); }
/** * @test */ public function shouldNeedReloadAfterSourceChanged() { $source = new InMemory(); $cache = new InMemory(); $cachedFs = new Cache($source, $cache); // The source has been updated after the cache has been created. $mtime = time(); $source->setFile('foo', 'baz', $mtime - 10); $cache->setFile('foo', 'bar', $mtime - 20); $this->assertTrue($cachedFs->needsReload('foo')); $this->assertEquals('baz', $cachedFs->read('foo')); }
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')); }
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')); }