本文整理汇总了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);
}
}