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


PHP UnitOfWork::expects方法代码示例

本文整理汇总了PHP中Doctrine\ORM\UnitOfWork::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitOfWork::expects方法的具体用法?PHP UnitOfWork::expects怎么用?PHP UnitOfWork::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\UnitOfWork的用法示例。


在下文中一共展示了UnitOfWork::expects方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSourceModified

 public function testSourceModified()
 {
     $changeset = ['datetimeLastVisited' => [null, new \DateTime()], 'data' => [null, ['foo' => 'bar']]];
     $this->uow->expects($this->once())->method('getEntityChangeSet')->will($this->returnValue($changeset));
     $listener = new SourceModificationListenerMock($this->sourceProcessor, $this->queueManager);
     $this->assertTrue($listener->visibleIsSourceModified(new SourceMock(12345), $this->uow));
 }
开发者ID:mvanduijker,项目名称:FMIoBundle,代码行数:7,代码来源:SourceModificationListenerTest.php

示例2: testRetrieveUserTracker

 public function testRetrieveUserTracker()
 {
     $user = new User();
     $tracker = $this->tracker();
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with(self::CLASS_NAME)->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('load')->with(['user' => $user], null, null, [], 0, 1, null)->will($this->returnValue($tracker));
     $this->repository->retrieveUserTracker($user);
 }
开发者ID:vdrizheruk,项目名称:OroCrmTimeLapBundle,代码行数:9,代码来源:DoctrineTimeTrackingRecordRepositoryTest.php

示例3: thatApiUserRetrievesByUsername

 /**
  * @test
  */
 public function thatApiUserRetrievesByUsername()
 {
     $email = 'test@domain.com';
     $apiUser = $this->getApiUser();
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::DUMMY_CLASS_NAME))->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('load')->with($this->equalTo(array('email' => $email)), $this->equalTo(null), $this->equalTo(null), array(), $this->equalTo(0), $this->equalTo(1), $this->equalTo(null))->will($this->returnValue($apiUser));
     $retrievedApiUser = $this->repository->findOneBy(array('email' => $email));
     $this->assertNotNull($retrievedApiUser);
     $this->assertEquals($apiUser, $retrievedApiUser);
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:14,代码来源:DoctrineApiUserRepositoryTest.php

示例4: testFindAllByTicket

 public function testFindAllByTicket()
 {
     $messageReference = $this->getMessageReference();
     $ticket = $messageReference->getTicket();
     $references = array($messageReference);
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::DUMMY_CLASS_NAME))->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('loadAll')->with($this->equalTo(array('ticket' => $ticket)), null, null, null)->will($this->returnValue($references));
     $result = $this->repository->findAllByTicket($ticket);
     $this->assertEquals($references, $result);
 }
开发者ID:northdakota,项目名称:DiamanteDeskBundle,代码行数:11,代码来源:DoctrineMessageReferenceRepositoryTest.php

示例5: thatBranchEmailConfigurationRetrievesByBranchId

 /**
  * @test
  */
 public function thatBranchEmailConfigurationRetrievesByBranchId()
 {
     $branchId = 1;
     $branchEmailConfiguration = $this->getBranchEmailConfiguartion();
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::DUMMY_CLASS_NAME))->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('load')->with($this->equalTo(array('branchId' => $branchId)), $this->equalTo(null), $this->equalTo(null), array(), $this->equalTo(0), $this->equalTo(1), $this->equalTo(null))->will($this->returnValue($branchEmailConfiguration));
     $retrievedBranchEmailConfiguration = $this->repository->findOneBy(array('branchId' => $branchId));
     $this->assertNotNull($retrievedBranchEmailConfiguration);
     $this->assertEquals($branchEmailConfiguration, $retrievedBranchEmailConfiguration);
 }
开发者ID:northdakota,项目名称:DiamanteDeskBundle,代码行数:14,代码来源:DoctrineBranchEmailConfigurationRepositoryTest.php

示例6: setUp

 public function setUp()
 {
     $this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $this->uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock();
     $this->persister = $this->getMockBuilder('Doctrine\\ORM\\Persisters\\BasicEntityPersister')->disableOriginalConstructor()->getMock();
     $this->em->expects($this->any())->method('getUnitOfWork')->will($this->returnValue($this->uow));
     $this->uow->expects($this->any())->method('getEntityPersister')->with('stdClass')->will($this->returnValue($this->persister));
     $this->entity = new stdClass();
     $metadata = new ClassMetadata('stdClass');
     $metadata->fieldMappings = array('property' => 'property');
     $metadata->identifier = array('id');
     $this->repository = new EntityRepository($this->em, $metadata);
 }
开发者ID:lstrojny,项目名称:doctrine-fun,代码行数:13,代码来源:EntityRepositoryTest.php

示例7: thatGetsAll

 /**
  * @test
  */
 public function thatGetsAll()
 {
     $entities = array(new EntityStub(), new EntityStub());
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::CLASS_NAME))->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('loadAll')->with($this->equalTo(array()), $this->equalTo(null), $this->equalTo(null), $this->equalTo(null))->will($this->returnValue($entities));
     $retrievedEntities = $this->repository->getAll();
     $this->assertEquals($entities, $retrievedEntities);
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:12,代码来源:DoctrineGenericRepositoryTest.php

示例8: testListAllByUserAndPeriod

 public function testListAllByUserAndPeriod()
 {
     $user = new User();
     $period = new Period(new \DateTime('2014-12-01'), new \DateTime('2014-12-31'));
     $worklogs = [$this->worklog()];
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork));
     $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with(self::CLASS_NAME)->will($this->returnValue($this->entityPersister));
     $this->entityPersister->expects($this->once())->method('loadCriteria')->with($this->logicalAnd($this->isInstanceOf('\\Doctrine\\Common\\Collections\\Criteria')))->will($this->returnValue($worklogs));
     $result = $this->repository->listAllByUserAndPeriod($user, $period);
     $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $result);
     $this->assertEquals($result->toArray(), $worklogs);
 }
开发者ID:vdrizheruk,项目名称:OroCrmTimeLapBundle,代码行数:12,代码来源:DoctrineWorklogRepositoryTest.php

示例9: persistAllRespectsObjectWhitelistIfOnlyWhitelistedObjectsFlagIsTrue

 /**
  * @test
  */
 public function persistAllRespectsObjectWhitelistIfOnlyWhitelistedObjectsFlagIsTrue()
 {
     $mockObject = new \stdClass();
     $scheduledEntityUpdates = array(spl_object_hash($mockObject) => $mockObject);
     $scheduledEntityDeletes = array();
     $scheduledEntityInsertions = array();
     $this->mockUnitOfWork->expects($this->any())->method('getScheduledEntityUpdates')->will($this->returnValue($scheduledEntityUpdates));
     $this->mockUnitOfWork->expects($this->any())->method('getScheduledEntityDeletions')->will($this->returnValue($scheduledEntityDeletes));
     $this->mockUnitOfWork->expects($this->any())->method('getScheduledEntityInsertions')->will($this->returnValue($scheduledEntityInsertions));
     $this->mockEntityManager->expects($this->once())->method('flush');
     $this->persistenceManager->whitelistObject($mockObject);
     $this->persistenceManager->persistAll(true);
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:16,代码来源:PersistenceManagerTest.php

示例10: testPopulateChannelOwner

 /**
  * @dataProvider defaultIntegrationOwnerProvider
  *
  * @param Integration $integration
  * @param string      $ownerType
  * @param bool        $expectedReload
  * @param bool        $expectedSet
  * @param bool        $expectedSetOrganization
  */
 public function testPopulateChannelOwner(Integration $integration, $ownerType, $expectedReload, $expectedSet, $expectedSetOrganization = false)
 {
     $entity = new \stdClass();
     $owner = $integration->getDefaultUserOwner();
     $organization = $integration->getOrganization();
     $doctrineMetadata = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadataInfo')->disableOriginalConstructor()->getMock();
     $this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValue($doctrineMetadata));
     if ($expectedReload) {
         $this->uow->expects($this->once())->method('getEntityState')->with($this->identicalTo($owner))->will($this->returnValue(UnitOfWork::STATE_DETACHED));
         $this->em->expects($this->once())->method('find')->with($this->equalTo(get_class($owner)))->will($this->returnValue($owner));
     }
     $ownerMetadata = new OwnershipMetadata($ownerType, self::USER_OWNER_FIELD_NAME, self::USER_OWNER_COLUMN_NAME, self::ORGANIZATION_FIELD_NAME);
     $this->metadataProvider->expects($this->any())->method('getMetadata')->with(get_class($entity))->will($this->returnValue($ownerMetadata));
     if ($expectedSet) {
         $doctrineMetadata->expects($this->once())->method('setFieldValue')->with($this->identicalTo($entity), self::USER_OWNER_FIELD_NAME, $this->identicalTo($owner));
     } elseif ($expectedSetOrganization) {
         $doctrineMetadata->expects($this->once())->method('setFieldValue')->with($this->identicalTo($entity), self::ORGANIZATION_FIELD_NAME, $this->identicalTo($organization));
     } else {
         $doctrineMetadata->expects($this->never())->method('setFieldValue');
     }
     $this->helper->populateChannelOwner($entity, $integration);
 }
开发者ID:Maksold,项目名称:platform,代码行数:31,代码来源:DefaultOwnerHelperTest.php

示例11: testFlush

 public function testFlush()
 {
     $changesetAnswer = ['seen' => true];
     $user1 = new User();
     $user1->setId(1);
     $user2 = new User();
     $user2->setId(2);
     $emailUser1 = new EmailUser();
     $emailUser1->setOwner($user1);
     $emailUser2 = new EmailUser();
     $emailUser2->setOwner($user2);
     $emailUserArray = [$emailUser1, $emailUser2, $emailUser1];
     $onFlushEventArgs = $this->getMockBuilder('Doctrine\\ORM\\Event\\OnFlushEventArgs')->setMethods(['getEntityManager'])->disableOriginalConstructor()->getMock();
     $onFlushEventArgs->expects($this->once())->method('getEntityManager')->will($this->returnValue($this->em));
     $this->uow->expects($this->any())->method('getEntityChangeSet')->will($this->returnValue($changesetAnswer));
     $this->uow->expects($this->any())->method('getScheduledEntityInsertions')->will($this->returnValue($emailUserArray));
     $this->uow->expects($this->any())->method('getScheduledEntityUpdates')->will($this->returnValue($emailUserArray));
     $this->processor->expects($this->exactly(1))->method('send')->with([$user1->getId() => ['entity' => $emailUser1, 'new' => 2], $user2->getId() => ['entity' => $emailUser2, 'new' => 1]]);
     $postFlushEventArgs = $this->getMockBuilder('Doctrine\\ORM\\Event\\PostFlushEventArgs')->disableOriginalConstructor()->getMock();
     $postFlushEventArgs->expects($this->any())->method('getEntityManager')->willReturn($this->em);
     $this->listener->onFlush($onFlushEventArgs);
     $this->listener->postFlush($postFlushEventArgs);
 }
开发者ID:Maksold,项目名称:platform,代码行数:23,代码来源:EmailUserListenerTest.php

示例12: testScheduleEntityUpdate

 public function testScheduleEntityUpdate()
 {
     $account = $this->getMock('OroCRM\\Bundle\\AccountBundle\\Entity\\Account');
     $channel = $this->getMock('OroCRM\\Bundle\\ChannelBundle\\Entity\\Channel');
     $customer = new CustomerEntity();
     $customer->setAccount($account)->setDataChannel($channel);
     $this->uow->expects($this->exactly(2))->method('isScheduledForDelete')->willReturn(false);
     $reflectionProperty = new \ReflectionProperty(get_class($this->channelDoctrineListener), 'uow');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->channelDoctrineListener, $this->uow);
     $this->assertAttributeEmpty('queued', $this->channelDoctrineListener);
     $this->channelDoctrineListener->scheduleEntityUpdate($customer, $account, $channel);
     $this->assertAttributeNotEmpty('queued', $this->channelDoctrineListener);
 }
开发者ID:rodolfobandeira,项目名称:crm,代码行数:14,代码来源:ChannelDoctrineListenerTest.php

示例13: testCollectNestingData

 /**
  * @dataProvider collectNestingDataDataProvider
  *
  * @param array $associations
  * @param array $mappings
  * @param int   $expectedCount
  */
 public function testCollectNestingData($associations, $mappings, $expectedCount)
 {
     $testData = new EntityStub();
     $reflection = new \ReflectionMethod($this->generator, 'collectNestedDataTags');
     $reflection->setAccessible(true);
     $this->uow->expects($this->any())->method('getEntityIdentifier')->will($this->returnValue(['someIdentifierValue']));
     $metadata = new ClassMetadata(self::TEST_ENTITY_NAME);
     $metadata->associationMappings = $mappings;
     foreach ($associations as $name => $dataValue) {
         $field = $this->getMockBuilder('\\ReflectionProperty')->disableOriginalConstructor()->getMock();
         $field->expects($this->once())->method('getValue')->with($testData)->will($this->returnValue($dataValue));
         $metadata->reflFields[$name] = $field;
     }
     $result = $reflection->invoke($this->generator, $testData, $metadata);
     $this->assertInternalType('array', $result, 'Should always return array');
     $this->assertCount($expectedCount, $result, 'Should not generate collection tag for associations');
 }
开发者ID:Maksold,项目名称:platform,代码行数:24,代码来源:DoctrineTagGeneratorTest.php


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