当前位置: 首页>>代码示例>>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;未经允许,请勿转载。