本文整理匯總了PHP中Doctrine\ORM\Event\LifecycleEventArgs::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP LifecycleEventArgs::expects方法的具體用法?PHP LifecycleEventArgs::expects怎麽用?PHP LifecycleEventArgs::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\Event\LifecycleEventArgs
的用法示例。
在下文中一共展示了LifecycleEventArgs::expects方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testPrePersist
/**
* @dataProvider getEntity
*
* @param \PHPUnit_Framework_MockObject_MockObject $entity
* @param string $filename
*/
public function testPrePersist(\PHPUnit_Framework_MockObject_MockObject $entity, $filename)
{
$this->args->expects($this->once())->method('getEntity')->will($this->returnValue($entity));
if ($entity instanceof Item || $entity instanceof Image) {
/* @var $entity \PHPUnit_Framework_MockObject_MockObject|Item|Image */
$time = $this->getMock('\\DateTime');
$time->expects($this->once())->method('format')->with('Y/m/d/His/')->will($this->returnValue('some/path'));
if ($entity instanceof Item) {
$entity->expects($this->once())->method('getDateAdd')->will($this->returnValue($time));
} else {
$item = $this->getMock('\\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Item');
$entity->expects($this->once())->method('getItem')->will($this->returnValue($item));
$item->expects($this->once())->method('getDateAdd')->will($this->returnValue($time));
}
$entity->expects($this->at(1))->method('getFilename')->will($this->returnValue($filename));
if ($filename) {
$entity->expects($this->at(2))->method('getFilename')->will($this->returnValue($filename));
}
if (strpos($filename, 'tmp') !== false) {
$entity->expects($this->at(3))->method('getFilename')->will($this->returnValue($filename));
$entity->expects($this->at(6))->method('getFilename')->will($this->returnValue('new_filename'));
$entity->expects($this->once())->method('setFilename')->with('some/path' . pathinfo($filename, PATHINFO_BASENAME));
$entity->expects($this->once())->method('getDownloadPath')->will($this->returnValue('web'));
$this->fs->expects($this->once())->method('copy')->with($this->root . 'web/' . $filename, $this->root . 'web/new_filename', true);
}
} else {
$entity->expects($this->never())->method('getFilename');
}
$this->listener->prePersist($this->args);
}
示例2: setUp
protected function setUp()
{
$this->entity = new \stdClass();
$this->keeper = $this->getNoConstructorMock(Keeper::class);
$this->builder = $this->getNoConstructorMock(CacheKeyBuilder::class);
$this->args = $this->getNoConstructorMock(LifecycleEventArgs::class);
$this->args->expects($this->atLeastOnce())->method('getEntity')->will($this->returnValue($this->entity));
}
示例3: getEntityExpectations
private function getEntityExpectations($setSize = true)
{
$fileSize = filesize(__DIR__ . '/../Fixtures/test.gif');
$file = new UploadedFile(__DIR__ . '/../Fixtures/test.gif', 'original.gif', null, $fileSize, UPLOAD_ERR_OK, true);
$this->entity->expects($this->any())->method('getFile')->willReturn($file);
$this->entity->expects($this->any())->method('getRemoteDir')->willReturn('remote/dir');
$this->args->expects($this->any())->method('getEntity')->willReturn($this->entity);
if ($setSize) {
$this->entity->expects($this->once())->method('setSize')->with($fileSize);
}
}