本文整理汇总了PHP中FileSystem::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::shouldReceive方法的具体用法?PHP FileSystem::shouldReceive怎么用?PHP FileSystem::shouldReceive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::shouldReceive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetFile
public function testGetFile()
{
$fs = new SymfonyFileSystem();
$someJunk = 'whatever dude';
$hash = md5($someJunk);
$testFilePath = $this->uploadDirectory . '/' . $hash;
file_put_contents($testFilePath, $someJunk);
$file = m::mock('Symfony\\Component\\HttpFoundation\\File\\File')->shouldReceive('getPathname')->andReturn($testFilePath)->getMock();
$this->mockFileSystem->shouldReceive('exists')->with($testFilePath)->andReturn(true);
$this->mockFileSystem->shouldReceive('move');
$newHash = $this->tempFileSystem->storeFile($file, false);
$newFile = $this->tempFileSystem->getFile($newHash);
$this->assertSame($hash, $newHash);
$this->assertSame(file_get_contents($newFile->getPathname()), $someJunk);
}
示例2: testCheckLearningMaterialFilePath
public function testCheckLearningMaterialFilePath()
{
$goodLm = m::mock('Ilios\\CoreBundle\\Entity\\LearningMaterial')->shouldReceive('getRelativePath')->andReturn('goodfile')->mock();
$badLm = m::mock('Ilios\\CoreBundle\\Entity\\LearningMaterial')->shouldReceive('getRelativePath')->andReturn('badfile')->mock();
$this->mockFileSystem->shouldReceive('exists')->with($this->fakeTestFileDir . '/goodfile')->andReturn(true)->once();
$this->mockFileSystem->shouldReceive('exists')->with($this->fakeTestFileDir . '/badfile')->andReturn(false)->once();
$this->assertTrue($this->iliosFileSystem->checkLearningMaterialFilePath($goodLm));
$this->assertFalse($this->iliosFileSystem->checkLearningMaterialFilePath($badLm));
}
示例3: testGetFile
public function testGetFile()
{
$fs = new SymfonyFileSystem();
$someJunk = 'whatever dude';
$hash = md5($someJunk);
$hashDirectory = substr($hash, 0, 2);
$parts = [$this->fakeTestFileDir, 'learning_materials', 'lm', $hashDirectory];
$dir = implode($parts, '/');
$fs->mkdir($dir);
$testFilePath = $dir . '/' . $hash;
file_put_contents($testFilePath, $someJunk);
$file = m::mock('Symfony\\Component\\HttpFoundation\\File\\File')->shouldReceive('getPathname')->andReturn($testFilePath)->getMock();
$this->mockFileSystem->shouldReceive('exists')->with($testFilePath)->andReturn(true);
$this->mockFileSystem->shouldReceive('mkdir');
$newPath = $this->iliosFileSystem->storeLearningMaterialFile($file, false);
$newFile = $this->iliosFileSystem->getFile($newPath);
$this->assertSame($newFile->getPathname(), $testFilePath);
$this->assertSame(file_get_contents($newFile->getPathname()), $someJunk);
$fs->remove($this->fakeTestFileDir . '/learning_materials');
}