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


PHP PHPUnit_Framework_MockObject_MockObject类代码示例

本文整理汇总了PHP中PHPUnit_Framework_MockObject_MockObject的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_MockObject_MockObject类的具体用法?PHP PHPUnit_Framework_MockObject_MockObject怎么用?PHP PHPUnit_Framework_MockObject_MockObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getMigration

 /**
  * Retrieves a mocked migration.
  *
  * @return \Drupal\migrate\Entity\MigrationInterface|\PHPUnit_Framework_MockObject_MockObject
  *   The mocked migration.
  */
 protected function getMigration()
 {
     $this->migrationConfiguration += ['migrationClass' => 'Drupal\\migrate\\Entity\\Migration'];
     $this->idMap = $this->getMock('Drupal\\migrate\\Plugin\\MigrateIdMapInterface');
     $this->idMap->method('getQualifiedMapTableName')->willReturn('test_map');
     $migration = $this->getMockBuilder($this->migrationConfiguration['migrationClass'])->disableOriginalConstructor()->getMock();
     $migration->method('checkRequirements')->willReturn(TRUE);
     $migration->method('getIdMap')->willReturn($this->idMap);
     // We need the state to be toggled throughout the test so we store the value
     // on the test class and use a return callback.
     $migration->expects($this->any())->method('getStatus')->willReturnCallback(function () {
         return $this->migrationStatus;
     });
     $migration->expects($this->any())->method('setStatus')->willReturnCallback(function ($status) {
         $this->migrationStatus = $status;
     });
     $migration->method('getMigrationDependencies')->willReturn(['required' => [], 'optional' => []]);
     $configuration =& $this->migrationConfiguration;
     $migration->method('get')->willReturnCallback(function ($argument) use(&$configuration) {
         return isset($configuration[$argument]) ? $configuration[$argument] : '';
     });
     $migration->method('set')->willReturnCallback(function ($argument, $value) use(&$configuration) {
         $configuration[$argument] = $value;
     });
     $migration->method('id')->willReturn($configuration['id']);
     return $migration;
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:33,代码来源:MigrateTestCase.php

示例2: testBuild

 public function testBuild()
 {
     $type = 'history';
     $userId = 1;
     $user = $this->getMockBuilder('stdClass')->setMethods(['getId'])->getMock();
     $user->expects($this->once())->method('getId')->will($this->returnValue($userId));
     $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $token->expects($this->once())->method('getUser')->will($this->returnValue($user));
     $this->tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($token));
     $item = $this->getMock('Oro\\Bundle\\NavigationBundle\\Entity\\NavigationItemInterface');
     $this->factory->expects($this->once())->method('createItem')->with($type, [])->will($this->returnValue($item));
     $repository = $this->getMockBuilder('Oro\\Bundle\\NavigationBundle\\Entity\\Repository\\HistoryItemRepository')->disableOriginalConstructor()->getMock();
     $items = [['id' => 1, 'title' => 'test1', 'url' => '/'], ['id' => 2, 'title' => 'test2', 'url' => '/home']];
     $repository->expects($this->once())->method('getNavigationItems')->with($userId, $type)->will($this->returnValue($items));
     $this->em->expects($this->once())->method('getRepository')->with(get_class($item))->will($this->returnValue($repository));
     $menu = $this->getMockBuilder('Knp\\Menu\\MenuItem')->disableOriginalConstructor()->getMock();
     $childMock = $this->getMock('Knp\\Menu\\ItemInterface');
     $childMock2 = clone $childMock;
     $children = [$childMock, $childMock2];
     $matcher = $this->getMock('\\Knp\\Menu\\Matcher\\Matcher');
     $matcher->expects($this->once())->method('isCurrent')->will($this->returnValue(true));
     $this->builder->setMatcher($matcher);
     $menu->expects($this->exactly(2))->method('addChild');
     $menu->expects($this->once())->method('setExtra')->with('type', $type);
     $menu->expects($this->once())->method('getChildren')->will($this->returnValue($children));
     $menu->expects($this->once())->method('removeChild');
     $n = rand(1, 10);
     $configMock = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Config\\UserConfigManager')->disableOriginalConstructor()->getMock();
     $configMock->expects($this->once())->method('get')->with($this->equalTo('oro_navigation.maxItems'))->will($this->returnValue($n));
     $this->manipulator->expects($this->once())->method('slice')->with($menu, 0, $n);
     $this->builder->setOptions($configMock);
     $this->builder->build($menu, [], $type);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:33,代码来源:NavigationHistoryBuilderTest.php

示例3: testGetProductId

 public function testGetProductId()
 {
     $productId = 1;
     $this->orderItemMock->expects($this->once())->method('getProductId')->willReturn($productId);
     $result = $this->item->getProductId($this->orderItemMock);
     $this->assertEquals($productId, $result);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:ItemTest.php

示例4: testSetGetBody

 public function testSetGetBody()
 {
     $body = 'my test body';
     $this->serializer->expects($this->once())->method('serialize')->with($this->equalTo($body), $this->equalTo(array()))->will($this->returnValue($body));
     $this->request->setBody($body);
     $this->assertSame($body, $this->request->getBody());
 }
开发者ID:thebennos,项目名称:php-client,代码行数:7,代码来源:DeleteByQueryRequestTest.php

示例5: testOnKernelControllerSubRequest

 public function testOnKernelControllerSubRequest()
 {
     $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('getRequestType')->will($this->returnValue(HttpKernel::SUB_REQUEST));
     $this->linkProvider->expects($this->never())->method($this->anything());
     $this->listener->onKernelController($event);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:7,代码来源:HelpLinkRequestListenerTest.php

示例6: testCheckUpdate

 /**
  * @dataProvider checkUpdateDataProvider
  * @param bool $callInbox
  * @param string $curlRequest
  */
 public function testCheckUpdate($callInbox, $curlRequest)
 {
     $mockName = 'Test Product Name';
     $mockVersion = '0.0.0';
     $mockEdition = 'Test Edition';
     $mockUrl = 'http://test-url';
     $this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
     $this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
     $this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
     $configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
     $lastUpdate = 0;
     $this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
     $this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
     $this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
     $this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
     $this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
     $this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
     $this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
     $this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
     if ($callInbox) {
         $this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
         $this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
     } else {
         $this->inboxFactory->expects($this->never())->method('create');
         $this->inboxModel->expects($this->never())->method('parse');
     }
     $this->feed->checkUpdate();
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:34,代码来源:FeedTest.php

示例7: truncate_multiple_tables_when_configured

 /**
  * @test
  */
 public function truncate_multiple_tables_when_configured()
 {
     $configuration = ['truncate' => ['test', 'test2', 'test3']];
     $processor = $this->getMockBuilder(Configuration::class)->disableOriginalConstructor()->getMock();
     $this->connection->expects($this->exactly(3))->method('exec_TRUNCATEquery')->withConsecutive(['test'], ['test2'], ['test3']);
     $this->fixture->execute($processor, $configuration);
 }
开发者ID:sirdiego,项目名称:importr,代码行数:10,代码来源:TruncateTableTest.php

示例8: testGetCcTypes

 /**
  * @covers \Magento\Braintree\Helper\CcType::getCcTypes
  */
 public function testGetCcTypes()
 {
     $this->ccTypeSource->expects(static::once())->method('toOptionArray')->willReturn(['label' => 'VISA', 'value' => 'VI']);
     $this->helper->getCcTypes();
     $this->ccTypeSource->expects(static::never())->method('toOptionArray');
     $this->helper->getCcTypes();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:CcTypeTest.php

示例9: testMetadataHandler

 public function testMetadataHandler()
 {
     $this->container->setParameter('ez_io.metadata_handlers', array('my_handler' => array('name' => 'my_handler', 'type' => 'test_handler')));
     $this->metadataConfigurationFactoryMock->expects($this->once())->method('getParentServiceId')->will($this->returnValue('test.io.metadata_handler.test_handler'));
     $this->compile();
     $this->assertContainerBuilderHasServiceDefinitionWithParent('test.io.metadata_handler.test_handler.my_handler', 'test.io.metadata_handler.test_handler');
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:7,代码来源:IOConfigurationPassTest.php

示例10: testSend

 /**
  * @param int $configValue
  * @param bool|null $forceSyncMode
  * @param bool|null $customerNoteNotify
  * @param bool|null $emailSendingResult
  * @dataProvider sendDataProvider
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testSend($configValue, $forceSyncMode, $customerNoteNotify, $emailSendingResult)
 {
     $comment = 'comment_test';
     $address = 'address_test';
     $configPath = 'sales_email/general/async_sending';
     $this->creditmemoMock->expects($this->once())->method('setSendEmail')->with(true);
     $this->globalConfig->expects($this->once())->method('getValue')->with($configPath)->willReturn($configValue);
     if (!$configValue || $forceSyncMode) {
         $addressMock = $this->getMock('Magento\\Sales\\Model\\Order\\Address', [], [], '', false);
         $this->addressRenderer->expects($this->any())->method('format')->with($addressMock, 'html')->willReturn($address);
         $this->orderMock->expects($this->any())->method('getBillingAddress')->willReturn($addressMock);
         $this->orderMock->expects($this->any())->method('getShippingAddress')->willReturn($addressMock);
         $this->creditmemoMock->expects($this->once())->method('getCustomerNoteNotify')->willReturn($customerNoteNotify);
         $this->creditmemoMock->expects($this->any())->method('getCustomerNote')->willReturn($comment);
         $this->templateContainerMock->expects($this->once())->method('setTemplateVars')->with(['order' => $this->orderMock, 'creditmemo' => $this->creditmemoMock, 'comment' => $customerNoteNotify ? $comment : '', 'billing' => $addressMock, 'payment_html' => 'payment', 'store' => $this->storeMock, 'formattedShippingAddress' => $address, 'formattedBillingAddress' => $address]);
         $this->identityContainerMock->expects($this->once())->method('isEnabled')->willReturn($emailSendingResult);
         if ($emailSendingResult) {
             $this->senderBuilderFactoryMock->expects($this->once())->method('create')->willReturn($this->senderMock);
             $this->senderMock->expects($this->once())->method('send');
             $this->senderMock->expects($this->once())->method('sendCopyTo');
             $this->creditmemoMock->expects($this->once())->method('setEmailSent')->with(true);
             $this->creditmemoResourceMock->expects($this->once())->method('saveAttribute')->with($this->creditmemoMock, ['send_email', 'email_sent']);
             $this->assertTrue($this->sender->send($this->creditmemoMock));
         } else {
             $this->creditmemoResourceMock->expects($this->once())->method('saveAttribute')->with($this->creditmemoMock, 'send_email');
             $this->assertFalse($this->sender->send($this->creditmemoMock));
         }
     } else {
         $this->creditmemoResourceMock->expects($this->once())->method('saveAttribute')->with($this->creditmemoMock, 'send_email');
         $this->assertFalse($this->sender->send($this->creditmemoMock));
     }
 }
开发者ID:opexsw,项目名称:magento2,代码行数:41,代码来源:CreditmemoSenderTest.php

示例11: testSaveDownloadableOrderItem

 public function testSaveDownloadableOrderItem()
 {
     $itemId = 100;
     $itemMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->getMock();
     $itemMock->expects($this->atLeastOnce())->method('getOrder')->willReturn($this->orderMock);
     $itemMock->expects($this->any())->method('getId')->willReturn($itemId);
     $itemMock->expects($this->any())->method('getProductType')->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
     $this->orderMock->expects($this->once())->method('getStoreId')->willReturn(10500);
     $product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $product->expects($this->once())->method('getTypeId')->willReturn(DownloadableProductType::TYPE_DOWNLOADABLE);
     $productType = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Product\\Type')->disableOriginalConstructor()->getMock();
     $product->expects($this->once())->method('getTypeInstance')->willReturn($productType);
     $product->expects($this->once())->method('setStoreId')->with(10500)->willReturnSelf();
     $product->expects($this->once())->method('load')->willReturnSelf();
     $this->productFactory->expects($this->once())->method('create')->willReturn($product);
     $linkItem = $this->createLinkItem(12, 12, true, 'pending');
     $this->itemFactory->expects($this->once())->method('create')->willReturn($linkItem);
     $productType->expects($this->once())->method('getLinks')->willReturn([123 => $linkItem]);
     $itemMock->expects($this->once())->method('getProductOptionByCode')->willReturn([123]);
     $itemMock->expects($this->once())->method('getProduct')->willReturn(null);
     $purchasedLink = $this->getMockBuilder('\\Magento\\Downloadable\\Model\\Link\\Purchased')->disableOriginalConstructor()->setMethods(['load', 'setLinkSectionTitle', 'save'])->getMock();
     $purchasedLink->expects($this->once())->method('load')->with($itemId, 'order_item_id')->willReturnSelf();
     $purchasedLink->expects($this->once())->method('setLinkSectionTitle')->willReturnSelf();
     $purchasedLink->expects($this->once())->method('save')->willReturnSelf();
     $this->purchasedFactory->expects($this->any())->method('create')->willReturn($purchasedLink);
     $event = new \Magento\Framework\DataObject(['item' => $itemMock]);
     $observer = new \Magento\Framework\Event\Observer(['event' => $event]);
     $this->saveDownloadableOrderItemObserver->execute($observer);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:SaveDownloadableOrderItemObserverTest.php

示例12: testIsApplicableOnEmailCampaign

 /**
  * @param EmailCampaign $emailCampaign
  * @param Campaign $campaign
  * @param bool $expected
  * @dataProvider staticCampaignProvider
  */
 public function testIsApplicableOnEmailCampaign($emailCampaign, $campaign, $expected)
 {
     $this->entityRepository->expects($this->any())->method('findOneBy')->will($this->returnValue($campaign));
     $this->managerRegistry->expects($this->any())->method('getManager')->will($this->returnValue($this->entityManager));
     $this->entityManager->expects($this->any())->method('getRepository')->will($this->returnValue($this->entityRepository));
     $this->assertEquals($expected, $this->placeholderFilter->isApplicableOnEmailCampaign($emailCampaign));
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:13,代码来源:EmailCampaignPlaceholderFilterTest.php

示例13: testGetRuleId

 public function testGetRuleId()
 {
     $ruleId = 42;
     $ruleMock = new \Magento\Framework\DataObject(['id' => $ruleId]);
     $this->registryMock->expects($this->once())->method('registry')->with(RegistryConstants::CURRENT_SALES_RULE)->willReturn($ruleMock);
     $this->assertEquals($ruleId, $this->model->getRuleId());
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:7,代码来源:GenericButtonTest.php

示例14: testLoad

 public function testLoad()
 {
     $height = 123;
     $image = $this->getMock('\\Imagine\\Image\\ImageInterface');
     $this->innerLoader->expects($this->once())->method('load')->with($image, $this->equalTo(array('heighten' => $height)))->will($this->returnValue($image));
     $this->assertSame($image, $this->loader->load($image, array($height)));
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:7,代码来源:ScaleHeightFilterLoaderTest.php

示例15: testOnFlushUpdateUser

 /**
  * Test existing user modification
  */
 public function testOnFlushUpdateUser()
 {
     $args = new OnFlushEventArgs($this->em);
     $user = new User();
     $org = new Organization();
     $org->setId(1);
     $org->setName('test');
     $user->addOrganization($org);
     $newCalendar = new Calendar();
     $newCalendar->setOwner($user);
     $newCalendar->setOrganization($org);
     $newConnection = new CalendarConnection($newCalendar);
     $newCalendar->addConnection($newConnection);
     $calendarMetadata = new ClassMetadata(get_class($newCalendar));
     $connectionMetadata = new ClassMetadata(get_class($newConnection));
     $this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValueMap([['Oro\\Bundle\\CalendarBundle\\Entity\\Calendar', $calendarMetadata], ['Oro\\Bundle\\CalendarBundle\\Entity\\CalendarConnection', $connectionMetadata]]));
     $calendarRepo = $this->getMockBuilder('\\Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $calendarRepo->expects($this->any())->method('findDefaultCalendar')->will($this->returnValue(false));
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->uow));
     $this->uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue([]));
     $this->uow->expects($this->once())->method('getScheduledEntityUpdates')->will($this->returnValue([$user]));
     $this->em->expects($this->any())->method('getRepository')->with('OroCalendarBundle:Calendar')->will($this->returnValue($calendarRepo));
     $this->em->expects($this->at(2))->method('persist')->with($this->equalTo($newCalendar));
     $this->em->expects($this->at(3))->method('persist')->with($this->equalTo($newConnection));
     $this->uow->expects($this->at(2))->method('computeChangeSet')->with($calendarMetadata, $newCalendar);
     $this->uow->expects($this->at(3))->method('computeChangeSet')->with($connectionMetadata, $newConnection);
     $this->listener->onFlush($args);
 }
开发者ID:xamin123,项目名称:platform,代码行数:31,代码来源:EntityListenerTest.php


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