当前位置: 首页>>代码示例>>PHP>>正文


PHP LifecycleEventArgs::expects方法代码示例

本文整理汇总了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);
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:36,代码来源:DownloaderTest.php

示例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));
 }
开发者ID:anime-db,项目名称:cache-time-keeper-bundle,代码行数:8,代码来源:DoctrineListenerTest.php

示例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);
     }
 }
开发者ID:aboutcoders,项目名称:file-distribution-bundle,代码行数:11,代码来源:FileLifecycleListenerTest.php


注:本文中的Doctrine\ORM\Event\LifecycleEventArgs::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。