當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectRepository::expects方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Persistence\ObjectRepository::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectRepository::expects方法的具體用法?PHP ObjectRepository::expects怎麽用?PHP ObjectRepository::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Persistence\ObjectRepository的用法示例。


在下文中一共展示了ObjectRepository::expects方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testFindSchedules

 public function testFindSchedules()
 {
     $limit = 2;
     $offset = 1;
     $this->repository->expects($this->once())->method('findBy')->with(array(), array(), $limit, $offset);
     $this->subject->findSchedules($limit, $offset);
 }
開發者ID:aboutcoders,項目名稱:scheduler-bundle,代碼行數:7,代碼來源:ScheduleManagerTest.php

示例2: testFindWithInvalidObject

 /**
  * @expectedException \Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException
  */
 public function testFindWithInvalidObject()
 {
     $this->loader->expects($this->atLeastOnce())->method('mapPathToId')->with('/foo/bar')->will($this->returnValue(1337));
     $this->loader->expects($this->never())->method('getStreamFromImage');
     $this->om->expects($this->atLeastOnce())->method('find')->with(null, 1337)->will($this->returnValue(null));
     $this->loader->find('/foo/bar');
 }
開發者ID:raphydev,項目名稱:onep,代碼行數:10,代碼來源:AbstractDoctrineLoaderTest.php

示例3: testFindSchedules

 public function testFindSchedules()
 {
     $limit = 5;
     $offset = 10;
     $this->repository->expects($this->once())->method('findBy')->with(array('isActive' => true), array(), $limit, $offset)->willReturn('foobar');
     $result = $this->subject->findSchedules($limit, $offset);
     $this->assertSame('foobar', $result);
 }
開發者ID:aboutcoders,項目名稱:job-bundle,代碼行數:8,代碼來源:ScheduleManagerTest.php

示例4: testGetNextValueWithNotExistingSequenceReturnsNextValue

 public function testGetNextValueWithNotExistingSequenceReturnsNextValue()
 {
     $sequenceName = 'ABC';
     $this->repository->expects($this->once())->method('findOneBy')->with(array('name' => $sequenceName))->willReturn(null);
     $this->objectManager->expects($this->any())->method('persist');
     $this->objectManager->expects($this->any())->method('flush');
     $result = $this->subject->getNextValue($sequenceName);
     $this->assertEquals(1, $result);
 }
開發者ID:aboutcoders,項目名稱:sequence-bundle,代碼行數:9,代碼來源:SequenceManagerTest.php

示例5: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $firstDomainConfiguration = $this->getMockBuilder('Kunstmaan\\AdminBundle\\Helper\\DomainConfigurationInterface')->disableOriginalConstructor()->getMock();
     $firstDomainConfiguration->expects($this->any())->method('getHost')->will($this->returnValue('sub.domain.com'));
     $secondDomainConfiguration = $this->getMockBuilder('Kunstmaan\\AdminBundle\\Helper\\DomainConfigurationInterface')->disableOriginalConstructor()->getMock();
     $secondDomainConfiguration->expects($this->any())->method('getHost')->will($this->returnValue('other.domain.com'));
     $this->repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $this->repository->expects($this->any())->method('findAll')->will($this->returnValue($this->getRedirects()));
     $this->firstObject = new RedirectRouter($this->repository, $firstDomainConfiguration);
     $this->secondObject = new RedirectRouter($this->repository, $secondDomainConfiguration);
 }
開發者ID:axelvnk,項目名稱:KunstmaanBundlesCMS,代碼行數:15,代碼來源:RedirectRouterTest.php

示例6: testTransformUsesDefaultQueryBuilderMethodConfiguration

 /**
  * Tests that the Transformer uses the query_builder_method configuration option
  * allowing configuration of createQueryBuilder call.
  */
 public function testTransformUsesDefaultQueryBuilderMethodConfiguration()
 {
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     $this->repository->expects($this->never())->method('customQueryBuilderCreator');
     $this->repository->expects($this->once())->method('createQueryBuilder')->with($this->equalTo(ElasticaToModelTransformer::ENTITY_ALIAS))->will($this->returnValue($qb));
     $transformer = new ElasticaToModelTransformer($this->registry, $this->objectClass);
     $class = new \ReflectionClass('FOS\\ElasticaBundle\\Doctrine\\ORM\\ElasticaToModelTransformer');
     $method = $class->getMethod('getEntityQueryBuilder');
     $method->setAccessible(true);
     $method->invokeArgs($transformer, array());
 }
開發者ID:anteros,項目名稱:FOSElasticaBundle,代碼行數:15,代碼來源:ElasticaToModelTransformerTest.php

示例7: testToMagentoData

 /**
  * @dataProvider sourceDataProvider
  *
  * @param mixed  $source
  * @param bool   $foundInDatabase
  * @param array  $expectedResult
  * @param string $exception
  */
 public function testToMagentoData($source, $foundInDatabase, $expectedResult, $exception = null)
 {
     if ($exception) {
         $this->setExpectedException($exception);
     }
     if ($foundInDatabase === true) {
         $region = new Region();
         $region->setRegionId(self::TEST_MAGENTO_REGION_ID);
         $this->repository->expects($this->once())->method('findOneBy')->will($this->returnValue($region));
     } elseif ($foundInDatabase === false) {
         $this->repository->expects($this->once())->method('findOneBy')->will($this->returnValue(null));
     }
     // more than one call should not provoke expectation errors
     $this->assertSame($expectedResult, $this->converter->toMagentoData($source));
     $this->assertSame($expectedResult, $this->converter->toMagentoData($source));
 }
開發者ID:dairdr,項目名稱:crm,代碼行數:24,代碼來源:RegionConverterTest.php

示例8: testOnPostSubmit

 /**
  * @param mixed $formData
  * @param bool $expects
  * @param bool $isFormValid
  * @param PriceList|null $priceList
  *
  * @dataProvider onPostSubmitDataProvider
  */
 public function testOnPostSubmit($formData, $expects, $isFormValid = true, $priceList = null)
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|FormEvent $event */
     $event = $this->getMockBuilder('Symfony\\Component\\Form\\FormEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('getData')->willReturn($formData);
     $rootForm = $this->getMock('Symfony\\Component\\Form\\FormInterface');
     $rootForm->expects($this->any())->method('isValid')->willReturn($isFormValid);
     $event->expects($this->any())->method('getForm')->willReturn($rootForm);
     if ($expects && $isFormValid) {
         $this->repository->expects($this->once())->method($this->getSetterMethodName())->with($formData, $priceList);
         $priceListFrom = $this->getMock('Symfony\\Component\\Form\\FormInterface');
         $priceListFrom->expects($this->once())->method('getData')->willReturn($priceList);
         $rootForm->expects($this->once())->method('get')->willReturn($priceListFrom);
     }
     $this->getExtension()->onPostSubmit($event);
 }
開發者ID:hafeez3000,項目名稱:orocommerce,代碼行數:24,代碼來源:AbstractPriceListExtensionTest.php

示例9: findBy

 /**
  * @test
  */
 public function findBy()
 {
     $return = array(new SimpleModel());
     $criteria = array('id' => 2);
     $this->objectRepository->expects($this->once())->method('findBy')->with($criteria)->will($this->returnValue($return));
     $this->assertEquals($return, $this->uut->findBy($criteria));
 }
開發者ID:fightmaster,項目名稱:dao,代碼行數:10,代碼來源:DoctrineManagerTest.php

示例10: testUsesHintsConfigurationIfGiven

 /**
  * Checks that the 'hints' parameter is used on the created query
  */
 public function testUsesHintsConfigurationIfGiven()
 {
     $query = $this->getMockBuilder('Doctrine\\ORM\\AbstractQuery')->setMethods(array('setHint', 'execute', 'setHydrationMode'))->disableOriginalConstructor()->getMockForAbstractClass();
     $query->expects($this->any())->method('setHydrationMode')->willReturnSelf();
     $query->expects($this->once())->method('setHint')->with('customHintName', 'Custom\\Hint\\Class')->willReturnSelf();
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     $qb->expects($this->any())->method('getQuery')->willReturn($query);
     $qb->expects($this->any())->method('expr')->willReturn($this->getMockBuilder('Doctrine\\ORM\\Query\\Expr')->getMock());
     $qb->expects($this->any())->method('andWhere')->willReturnSelf();
     $this->repository->expects($this->once())->method('createQueryBuilder')->with($this->equalTo(ElasticaToModelTransformer::ENTITY_ALIAS))->will($this->returnValue($qb));
     $transformer = new ElasticaToModelTransformer($this->registry, $this->objectClass, array('hints' => array(array('name' => 'customHintName', 'value' => 'Custom\\Hint\\Class'))));
     $class = new \ReflectionClass('FOS\\ElasticaBundle\\Doctrine\\ORM\\ElasticaToModelTransformer');
     $method = $class->getMethod('findByIdentifiers');
     $method->setAccessible(true);
     $method->invokeArgs($transformer, array(array(1, 2, 3), true));
 }
開發者ID:alekitto,項目名稱:FOSElasticaBundle,代碼行數:19,代碼來源:ElasticaToModelTransformerTest.php

示例11: testFindBy

 public function testFindBy()
 {
     $criteria = array('foo');
     $orderBy = array('foo' => 'bar');
     $limit = 2;
     $offset = 1;
     $this->repository->expects($this->once())->method('findBy')->with($criteria, $orderBy, $limit, $offset);
     $this->subject->findBy($criteria, $orderBy, $limit, $offset);
 }
開發者ID:aboutcoders,項目名稱:job-bundle,代碼行數:9,代碼來源:JobManagerTest.php

示例12: testReleaseWithExistingLockReturnsTrue

 public function testReleaseWithExistingLockReturnsTrue()
 {
     $lockName = 'ABC';
     $lockNameWithPrefix = $this->prefix . '-ABC';
     $this->repository->expects($this->once())->method('findOneBy')->with(['name' => $lockNameWithPrefix])->willReturn(new ResourceLock());
     $this->objectManager->expects($this->once())->method('remove');
     $this->objectManager->expects($this->once())->method('flush');
     $result = $this->subject->release($lockName);
     $this->assertTrue($result);
 }
開發者ID:aboutcoders,項目名稱:resource-lock-bundle,代碼行數:10,代碼來源:LockManagerTest.php

示例13: testOnRemovedRemovePlugin

 public function testOnRemovedRemovePlugin()
 {
     $plugin = $this->getMock('\\AnimeDb\\Bundle\\AppBundle\\Entity\\Plugin');
     $this->rep->expects($this->once())->method('find')->will($this->returnValue($plugin))->with('foo/bar');
     $this->em->expects($this->once())->method('remove')->with($plugin);
     $this->em->expects($this->once())->method('flush');
     // test
     $event = '\\AnimeDb\\Bundle\\AnimeDbBundle\\Event\\Package\\Removed';
     $this->listener->onRemoved($this->getEvent($this->getPackage(), $event));
 }
開發者ID:anime-db,項目名稱:app-bundle,代碼行數:10,代碼來源:PackageTest.php

示例14: testLoadChoicesForValuesLoadsOnlyChoicesIfValueIsIdReader

 public function testLoadChoicesForValuesLoadsOnlyChoicesIfValueIsIdReader()
 {
     $loader = new DoctrineChoiceLoader($this->om, $this->class, $this->idReader, $this->objectLoader);
     $choices = array($this->obj2, $this->obj3);
     $value = array($this->idReader, 'getIdValue');
     $this->idReader->expects($this->any())->method('isSingleId')->willReturn(true);
     $this->idReader->expects($this->any())->method('getIdField')->willReturn('idField');
     $this->repository->expects($this->never())->method('findAll');
     $this->objectLoader->expects($this->once())->method('getEntitiesByIds')->with('idField', array('2'))->willReturn($choices);
     $this->idReader->expects($this->any())->method('getIdValue')->willReturnMap(array(array($this->obj2, '2'), array($this->obj3, '3')));
     $this->assertSame(array($this->obj2), $loader->loadChoicesForValues(array('2'), $value));
 }
開發者ID:ayoah,項目名稱:symfony,代碼行數:12,代碼來源:DoctrineChoiceLoaderTest.php

示例15: testFindByChannel

 public function testFindByChannel()
 {
     $channel = 'Channel';
     $this->repository->expects($this->once())->method('findBy')->with(['channel' => $channel]);
     $this->subject->findByChannel($channel);
 }
開發者ID:aboutcoders,項目名稱:job-bundle,代碼行數:6,代碼來源:LogManagerTest.php


注:本文中的Doctrine\Common\Persistence\ObjectRepository::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。