本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectManager::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::expects方法的具体用法?PHP ObjectManager::expects怎么用?PHP ObjectManager::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSaveWithFlush
public function testSaveWithFlush()
{
$entity = $this->subject->create();
$this->objectManager->expects($this->once())->method('persist')->with($entity);
$this->objectManager->expects($this->never())->method('flush');
$this->subject->save($entity, false);
}
示例2: testDelete
public function testDelete()
{
$entity = $this->subject->create();
$this->objectManager->expects($this->once())->method('remove')->with($entity);
$this->objectManager->expects($this->once())->method('flush');
$this->subject->delete($entity);
}
示例3: prepareServices
protected function prepareServices()
{
$this->form->expects($this->once())->method('setData')->with($this->entity);
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->request->setMethod('POST');
$this->form->expects($this->once())->method('isValid')->willReturn(true);
$this->manager->expects($this->at(0))->method('persist')->with($this->isType('object'));
$repository = $this->getMockBuilder('OroB2B\\Bundle\\PricingBundle\\Entity\\Repository\\PriceListRepository')->disableOriginalConstructor()->getMock();
$repository->expects($this->any())->method('setPriceListToAccount')->will($this->returnCallback(function (Account $account, PriceList $priceList = null) {
$this->entity->removeAccount($account);
if ($priceList) {
$this->entity->addAccount($account);
}
}));
$repository->expects($this->any())->method('setPriceListToAccountGroup')->will($this->returnCallback(function (AccountGroup $accountGroup, PriceList $priceList = null) {
$this->entity->removeAccountGroup($accountGroup);
if ($priceList) {
$this->entity->addAccountGroup($accountGroup);
}
}));
$repository->expects($this->any())->method('setPriceListToWebsite')->will($this->returnCallback(function (Website $website, PriceList $priceList = null) {
$this->entity->removeWebsite($website);
if ($priceList) {
$this->entity->addWebsite($website);
}
}));
$this->manager->expects($this->any())->method('getRepository')->with($this->isType('string'))->willReturn($repository);
$this->manager->expects($this->exactly(2))->method('flush');
}
示例4: testOnDuplicateAfterSourceProductWithoutPrices
public function testOnDuplicateAfterSourceProductWithoutPrices()
{
$this->productPriceRepository->expects($this->once())->method('getPricesByProduct')->with($this->sourceProduct)->will($this->returnValue([]));
$this->objectManager->expects($this->never())->method('persist');
$event = new ProductDuplicateAfterEvent($this->product, $this->sourceProduct);
$this->listener->onDuplicateAfter($event);
}
示例5: testProcessValidData
public function testProcessValidData()
{
$appendedUser = new User();
$appendedUser->setId(1);
$removedUser = new User();
$removedUser->setId(2);
$removedUser->addBusinessUnit($this->entity);
$this->form->expects($this->once())->method('setData')->with($this->entity);
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->request->setMethod('POST');
$this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
$appendForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
$appendForm->expects($this->once())->method('getData')->will($this->returnValue(array($appendedUser)));
$this->form->expects($this->at(3))->method('get')->with('appendUsers')->will($this->returnValue($appendForm));
$removeForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
$removeForm->expects($this->once())->method('getData')->will($this->returnValue(array($removedUser)));
$this->form->expects($this->at(4))->method('get')->with('removeUsers')->will($this->returnValue($removeForm));
$this->manager->expects($this->at(0))->method('persist')->with($appendedUser);
$this->manager->expects($this->at(1))->method('persist')->with($removedUser);
$this->manager->expects($this->at(2))->method('persist')->with($this->entity);
$this->manager->expects($this->once())->method('flush');
$this->assertTrue($this->handler->process($this->entity));
$businessUnits = $appendedUser->getBusinessUnits()->toArray();
$this->assertCount(1, $businessUnits);
$this->assertEquals($this->entity, current($businessUnits));
$this->assertCount(0, $removedUser->getBusinessUnits()->toArray());
}
示例6: testGetLoaded
/**
* Test get loaded settings
*/
public function testGetLoaded()
{
$loadedSettings = $this->loadedSettings;
$repository = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Entity\\Repository\\ConfigRepository')->disableOriginalConstructor()->getMock();
$repository->expects($this->at(0))->method('loadSettings')->with('user', 0)->will($this->returnValue($loadedSettings));
$repository->expects($this->at(1))->method('loadSettings')->with('app', 0)->will($this->returnValue($loadedSettings));
$this->om->expects($this->exactly(2))->method('getRepository')->will($this->returnValue($repository));
$this->object->get('oro_user.level');
}
示例7: 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);
}
示例8: testRemove
public function testRemove()
{
/** @var NotificationInterface $notification */
$notification = $this->getMock(NotificationInterface::class);
$this->objectManager->expects($this->at(0))->method('remove')->with($notification);
$this->objectManager->expects($this->at(0))->method('flush');
$result = $this->mapper->remove($notification);
$this->assertTrue($result);
}
示例9: testProcessValidData
public function testProcessValidData()
{
$this->request->setMethod('POST');
$this->form->expects($this->once())->method('setData')->with($this->entity);
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
$this->manager->expects($this->once())->method('persist')->with($this->entity);
$this->manager->expects($this->once())->method('flush');
$this->assertTrue($this->handler->process($this->entity));
}
示例10: testSavingAlreadyPersistedAddress
/**
* Tests the method when the address being saved is already persisted.
*/
public function testSavingAlreadyPersistedAddress()
{
$originalAddress = $this->getAddress('42', 'New address');
$clonedAddress = $this->getAddress(null, 'New address');
$this->addressObjectManagerMock->expects($this->once())->method('persist')->with($clonedAddress);
$this->addressObjectManagerMock->expects($this->once())->method('flush')->with($clonedAddress);
$this->addressEventDispatcher->expects($this->once())->method('dispatchAddressOnCloneEvent');
$savedAddress = $this->addressManager->saveAddress($originalAddress);
$this->assertEquals($savedAddress, $clonedAddress, 'The saved address should be a new one');
}
示例11: setUp
protected function setUp()
{
$class = Layout::class;
$this->repo = $this->getMockBuilder(ObjectRepository::class)->getMock();
$this->om = $this->getMockBuilder(ObjectManager::class)->getMock();
$this->om->expects($this->once())->method('getRepository')->with($class)->will($this->returnValue($this->repo));
/* @var ManagerRegistry|\PHPUnit_Framework_MockObject_MockObject $registry */
$registry = $this->getMockBuilder(ManagerRegistry::class)->getMock();
$registry->expects($this->once())->method('getManagerForClass')->with($class)->will($this->returnValue($this->om));
$this->loader = new EntityLayoutLoader($registry, $class);
}
示例12: setUp
public function setUp()
{
$this->routeMock = $this->buildMock('Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Orm\\Route');
$this->route2Mock = $this->buildMock('Symfony\\Cmf\\Bundle\\RoutingBundle\\Doctrine\\Orm\\Route');
$this->objectManagerMock = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
$this->managerRegistryMock = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
$this->objectRepositoryMock = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->setMethods(array('findByStaticPrefix', 'findOneBy', 'findBy'))->disableOriginalConstructor()->getMock();
$this->candidatesMock = $this->getMock('Symfony\\Cmf\\Component\\Routing\\Candidates\\CandidatesInterface');
$this->candidatesMock->expects($this->any())->method('isCandidate')->will($this->returnValue(true));
$this->managerRegistryMock->expects($this->any())->method('getManager')->will($this->returnValue($this->objectManagerMock));
$this->objectManagerMock->expects($this->any())->method('getRepository')->with('Route')->will($this->returnValue($this->objectRepositoryMock));
}
示例13: testProcessValidPost
public function testProcessValidPost()
{
$offerData = ['offer', 'data'];
$quote = new Quote();
$order = new Order();
$this->request->setMethod('POST');
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->form->expects($this->once())->method('isValid')->willReturn(true);
$this->form->expects($this->once())->method('getData')->willReturn($offerData);
$this->converter->expects($this->once())->method('convert')->with($quote, $this->accountUser, $offerData)->willReturn($order);
$this->manager->expects($this->once())->method('persist')->with($order);
$this->manager->expects($this->once())->method('flush');
$this->assertEquals($order, $this->handler->process($quote));
}
示例14: setUp
protected function setUp()
{
$this->factory = $this->getMock('Symfony\\Component\\Form\\ChoiceList\\Factory\\ChoiceListFactoryInterface');
$this->om = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager');
$this->repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
$this->class = 'stdClass';
$this->idReader = $this->getMockBuilder('Symfony\\Bridge\\Doctrine\\Form\\ChoiceList\\IdReader')->disableOriginalConstructor()->getMock();
$this->objectLoader = $this->getMock('Symfony\\Bridge\\Doctrine\\Form\\ChoiceList\\EntityLoaderInterface');
$this->obj1 = (object) array('name' => 'A');
$this->obj2 = (object) array('name' => 'B');
$this->obj3 = (object) array('name' => 'C');
$this->om->expects($this->any())->method('getRepository')->with($this->class)->willReturn($this->repository);
$this->om->expects($this->any())->method('getClassMetadata')->with($this->class)->willReturn(new ClassMetadata($this->class));
}
示例15: setUp
protected function setUp()
{
$this->objectRepository = $this->getMockForClass('Oro\\Bundle\\EmailBundle\\Entity\\Repository\\EmailTemplateRepository');
$this->objectManager = $this->getMockForClass('Doctrine\\Common\\Persistence\\ObjectManager');
$this->objectManager->expects($this->any())->method('getRepository')->with('OroEmailBundle:EmailTemplate')->willReturn($this->objectRepository);
$this->managerRegistry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
$this->managerRegistry->expects($this->any())->method('getManagerForClass')->with('OroEmailBundle:EmailTemplate')->willReturn($this->objectManager);
$this->configManager = $this->getMockForClass('Oro\\Bundle\\ConfigBundle\\Config\\ConfigManager');
$this->configManager->expects($this->any())->method('get')->willReturnMap([['oro_notification.email_notification_sender_email', false, false, self::FROM_EMAIL], ['oro_notification.email_notification_sender_name', false, false, self::FROM_NAME]]);
$this->renderer = $this->getMockForClass('Oro\\Bundle\\EmailBundle\\Provider\\EmailRenderer');
$this->emailHolderHelper = $this->getMockForClass('Oro\\Bundle\\EmailBundle\\Tools\\EmailHolderHelper');
$this->mailer = $this->getMockForClass('\\Swift_Mailer');
$this->mailProcessor = new BaseProcessor($this->managerRegistry, $this->configManager, $this->renderer, $this->emailHolderHelper, $this->mailer);
$this->emailTemplate = $this->getMock('Oro\\Bundle\\EmailBundle\\Model\\EmailTemplateInterface');
}