/** * @dataProvider analyze_dp */ public function testAnalyze($data, $file_content, $expected) { $f = new vfsStreamFile('file.php', 0664); $f->withContent($file_content); $this->fs->addChild($f); $this->fa->analyze($data); $this->assertEquals($expected, $data); }
/** * @dataProvider analyze_dp */ function testAnalyze($data, $file_content, $expected) { foreach ($data['files'] as $k => $file) { $f = new vfsStreamFile($file, 0664); $f->withContent($file_content[$k]); $this->fsroot->addChild($f); $data['files'][$k] = vfsStream::url($data['files'][$k]); } $this->ua->analyze($data); $this->assertEquals($expected, $data); }
protected function setUp() { global $xml_file_data; TestRequire::vfs($this); vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('r')); $this->fs = vfsStreamWrapper::getRoot(); $f = new vfsStreamFile('file.xml', 0664); $f->withContent($xml_file_data); $this->fs->addChild($f); $this->xa = new XMLAnalyzer(vfsStream::url('file.xml')); }
/** * @test * @group issue_33 * @since 1.1.0 */ public function truncateToGreaterSizeAddsZeroBytes() { $this->assertEquals(11, $this->file->write("lorem ipsum")); $this->assertTrue($this->file->truncate(25)); $this->assertEquals(25, $this->file->size()); $this->assertEquals("lorem ipsum", $this->file->getContent()); }
/** * setting and retrieving owner group of a file * * @test * @group permissions */ public function group() { $this->assertEquals(vfsStream::getCurrentGroup(), $this->file->getGroup()); $this->assertTrue($this->file->isOwnedByGroup(vfsStream::getCurrentGroup())); $this->assertSame($this->file, $this->file->chgrp(vfsStream::GROUP_USER_1)); $this->assertEquals(vfsStream::GROUP_USER_1, $this->file->getGroup()); $this->assertTrue($this->file->isOwnedByGroup(vfsStream::GROUP_USER_1)); }
/** * constructor * * @param string $name * @param int $permissions optional */ public function __construct($name, $permissions = null) { if (empty($name)) { throw new vfsStreamException('Name of Block device was empty'); } parent::__construct($name, $permissions); $this->type = vfsStreamContent::TYPE_BLOCK; }
protected function setTestData(array $identities) { $content = ''; foreach ($identities as $identity) { $line = "{$identity[0]}:{$identity[1]}:" . md5("{$identity[0]}:{$identity[1]}:{$identity[2]}") . PHP_EOL; $content .= $line; } file_put_contents($this->file->url(), $content); }
public function testGetStrings_endToEnd_severalLanguageFiles() { $ruDir = new vfsStreamDirectory('ru'); $faDir = new vfsStreamDirectory('fa'); $ruFile = new vfsStreamFile('language.php'); $ruFile->setContent(file_get_contents(__DIR__ . '/fixtures/language_ru_original.php')); $ruDir->addChild($ruFile); $faFile = new vfsStreamFile('language.php'); $faFile->setContent(file_get_contents(__DIR__ . '/fixtures/language_fa_original.php')); $faDir->addChild($faFile); $this->langDir->addChild($ruDir); $this->langDir->addChild($faDir); $obj = new Language_GetStrings(new Language_CollectFiles(), new Language_WriteFile_Factory(), array('baseDir' => vfsStream::url('root'))); $obj->addFileType(new Language_FileType_Php()); $obj->addFileType(new Language_FileType_Tpl()); $obj->run(); $this->assertEquals(file_get_contents(__DIR__ . '/fixtures/language_ru_modified.php'), file_get_contents(vfsStream::url('root/lang/ru/language.php'))); $this->assertEquals(file_get_contents(__DIR__ . '/fixtures/language_fa_modified.php'), file_get_contents(vfsStream::url('root/lang/fa/language.php'))); }
public function testCollectString_shouldNotConsiderEmptyCallsToTra() { $this->obj->addFileType(new Language_FileType_Php()); $fileName = 'file1.php'; $root = vfsStream::setup('root'); $file = new vfsStreamFile($fileName); $file->setContent("'sub' => array(\n\t\t\t 'required' => false,\n\t\t\t 'default' => 'n',\n\t\t\t 'filter' => 'alpha',\n\t\t\t 'options' => array(\n\t\t\t array('text' => tra(''), 'value' => ''),\n\t\t\t array('text' => tra('Yes'), 'value' => 'y'),\n\t\t\t array('text' => tra('No'), 'value' => 'n')\n\t\t\t ),\n\t\t\t ),"); $root->addChild($file); $expectedResult = array('Yes', 'No'); $this->assertEquals($expectedResult, $this->obj->collectStrings(vfsStream::url('root/' . $fileName))); }
public function testYouCanFetchAChart() { $chart = new Chart(new StringType('foo bar'), new Organisation(new IntType(1), new StringType('Foo Org'), Factory::create('gbp'))); file_put_contents($this->root->url() . '/foo_bar.saccount', serialize($chart)); $this->assertEquals($chart, $this->sut->fetch(new StringType('foo bar'))); }
/** * returns status of stream * * @return array */ public function stream_stat() { $fileStat = array('dev' => 0, 'ino' => 0, 'mode' => $this->content->getType() | $this->content->getPermissions(), 'nlink' => 0, 'uid' => $this->content->getUser(), 'gid' => $this->content->getGroup(), 'rdev' => 0, 'size' => $this->content->size(), 'atime' => $this->content->filemtime(), 'mtime' => $this->content->filemtime(), 'ctime' => $this->content->filemtime(), 'blksize' => -1, 'blocks' => -1); return array_merge(array_values($fileStat), $fileStat); }
/** * @test * @group issue_79 * @expectedException \InvalidArgumentException * @since 1.3.0 */ public function withContentThrowsInvalidArgumentExceptionWhenContentIsNoStringAndNoFileContent() { $this->file->withContent(313); }
/** * set lock status for stream * * @param int $operation * @return bool * @since 0.10.0 * @link https://github.com/mikey179/vfsStream/issues/6 */ public function stream_lock($operation) { $this->content->lock($operation); return true; }
/** * visit a file and process it * * @param vfsStreamFile $file * @return vfsStreamStructureVisitor */ public function visitFile(vfsStreamFile $file) { $this->current[$file->getName()] = $file->getContent(); return $this; }
public function testCanCreateADigestEntry() { $this->object->create(new StringType('foo'), new StringType('bar')); $fileContent = file_get_contents($this->file->url()); $this->assertRegExp('/^foo:realm:.*$/', $fileContent); }
/** * @test */ public function createFileWithDifferentUmaskSetting() { vfsStream::umask(022); $file = new vfsStreamFile('foo'); $this->assertEquals(0644, $file->getPermissions()); }