當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。