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);
 }
 public function testDisplay()
 {
     $this->markTestSkipped('Remove it when task(MAGETWO-33495) will be fixed');
     $this->_response->expects($this->atLeastOnce())->method('sendHeaders');
     $this->_request->expects($this->atLeastOnce())->method('getHeader');
     $stat = (include __DIR__ . '/_files/timers.php');
     $this->_output->display($stat);
     $actualHeaders = $this->_response->getHeaders();
     $this->assertNotEmpty($actualHeaders);
     $actualProtocol = false;
     $actualProfilerData = false;
     foreach ($actualHeaders as $oneHeader) {
         $headerName = $oneHeader->getFieldName();
         $headerValue = $oneHeader->getFieldValue();
         if (!$actualProtocol && $headerName == 'X-Wf-Protocol-1') {
             $actualProtocol = $headerValue;
         }
         if (!$actualProfilerData && $headerName == 'X-Wf-1-1-1-1') {
             $actualProfilerData = $headerValue;
         }
     }
     $this->assertNotEmpty($actualProtocol, 'Cannot get protocol header');
     $this->assertNotEmpty($actualProfilerData, 'Cannot get profiler header');
     $this->assertContains('Protocol/JsonStream', $actualProtocol);
     $this->assertRegExp('/"Type":"TABLE","Label":"Code Profiler \\(Memory usage: real - \\d+, emalloc - \\d+\\)"/', $actualProfilerData);
     $this->assertContains('[' . '["Timer Id","Time","Avg","Cnt","Emalloc","RealMem"],' . '["root","0.080000","0.080000","1","1,000","50,000"],' . '[". init","0.040000","0.040000","1","200","2,500"],' . '[". . init_store","0.020000","0.010000","2","100","2,000"],' . '["system","0.030000","0.015000","2","400","20,000"]' . ']', $actualProfilerData);
 }
 public function testShouldUnsubscribeMember()
 {
     $this->CCMemberServiceMock->expects($this->once())->method('unjoinMemberByEmail')->with('*****@*****.**');
     $service = new CCManagerMemberService($this->CCMemberServiceMock);
     $response = $service->unsubscribe('*****@*****.**');
     $this->assertTrue($response);
 }
Exemple #4
0
 /**
  * @dataProvider readDataProvider
  * @param string|null $storeCode
  * @param string $storeMethod
  */
 public function testRead($storeCode, $storeMethod)
 {
     $websiteCode = 'default';
     $storeId = 1;
     $defaultStoreCode = 'foostore';
     $defaultStoreId = 2;
     $websiteMock = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $websiteMock->expects($this->any())->method('getCode')->will($this->returnValue($websiteCode));
     $this->_storeMock->expects($this->any())->method('getWebsite')->will($this->returnValue($websiteMock));
     $this->_storeMock->expects($this->any())->method('load')->with($storeCode);
     $this->_storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId));
     $this->_storeMock->expects($this->any())->method('getCode')->will($this->returnValue($websiteCode));
     $this->_defaultStoreMock->expects($this->any())->method('getWebsite')->will($this->returnValue($websiteMock));
     $this->_defaultStoreMock->expects($this->any())->method('load')->with($defaultStoreCode);
     $this->_defaultStoreMock->expects($this->any())->method('getId')->will($this->returnValue($defaultStoreId));
     $this->_defaultStoreMock->expects($this->any())->method('getCode')->will($this->returnValue($defaultStoreCode));
     $dataMock = $this->getMock('Magento\\Framework\\App\\Config\\Data', [], [], '', false);
     $dataMock->expects($this->any())->method('getValue')->will($this->returnValue(['config' => ['key0' => 'website_value0', 'key1' => 'website_value1']]));
     $dataMock->expects($this->once())->method('getSource')->will($this->returnValue(['config' => ['key0' => 'website_value0', 'key1' => 'website_value1']]));
     $this->_scopePullMock->expects($this->once())->method('getScope')->with('website', $websiteCode)->will($this->returnValue($dataMock));
     $this->_initialConfigMock->expects($this->once())->method('getData')->with("stores|{$storeCode}")->will($this->returnValue(['config' => ['key1' => 'store_value1', 'key2' => 'store_value2']]));
     $this->_collectionFactory->expects($this->once())->method('create')->with(['scope' => 'stores', 'scopeId' => $storeId])->will($this->returnValue([new Object(['path' => 'config/key1', 'value' => 'store_db_value1']), new Object(['path' => 'config/key3', 'value' => 'store_db_value3'])]));
     $this->_storeManagerMock->expects($this->any())->method('getDefaultStoreView')->will($this->returnValue($this->_defaultStoreMock));
     $this->_storeManagerMock->expects($this->any())->method($storeMethod)->will($this->returnValue($this->_storeMock));
     $expectedData = ['config' => ['key0' => 'website_value0', 'key1' => 'store_db_value1', 'key2' => 'store_value2', 'key3' => 'store_db_value3']];
     $this->assertEquals($expectedData, $this->_model->read($storeCode));
 }
 /**
  * @dataProvider getBreadcrumbManagerDataProvider
  * @param $expected
  * @param $menu
  * @param $route
  */
 public function testGetBreadcrumbLabels($expected, $menu, $route)
 {
     $this->provider->expects($this->any())->method('get')->will($this->returnCallback(function ($menu) {
         switch ($menu) {
             case BreadcrumbManager::FRONTEND_MENU:
                 $item = new MenuItem('frontend_menu__test', $this->factory);
                 $item->setExtra('routes', ['another_route', '/another_route/', 'another*route', 'route_with_frontend_true']);
                 $item1 = new MenuItem('frontend_menu__test1', $this->factory);
                 $item2 = new MenuItem('frontend_menu__sub_item', $this->factory);
                 $item1->addChild($item2);
                 $item1->setExtra('routes', []);
                 $item2->addChild($item);
                 return $item1;
             case 'test_menu':
                 $item = new MenuItem('test_menu__test', $this->factory);
                 $item->setExtra('routes', ['another_route', '/another_route/', 'another*route', 'route_without_frontend']);
                 $item1 = new MenuItem('test_menu__test1', $this->factory);
                 $item2 = new MenuItem('test_menu__sub_item', $this->factory);
                 $item1->addChild($item2);
                 $item1->setExtra('routes', []);
                 $item2->addChild($item);
                 return $item1;
         }
         return null;
     }));
     $this->assertEquals($expected, $this->manager->getBreadcrumbLabels($menu, $route));
 }
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->authorize = $this->getMock('BjyAuthorize\\Service\\Authorize', array(), array(), '', false);
     $this->locator = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface');
     $this->initializer = new AuthorizeAwareServiceInitializer();
     $this->locator->expects($this->any())->method('get')->will($this->returnValue($this->authorize));
 }
Exemple #7
0
 public function testIsDevAllowed()
 {
     $store = 'some store';
     $result = 'result';
     $this->helperMock->expects($this->once())->method('isDevAllowed')->with($store)->will($this->returnValue($result));
     $this->assertEquals($result, $this->model->isDevAllowed($store));
 }
Exemple #8
0
 /**
  * Test method loadByKey()
  */
 public function testLoadByKey()
 {
     $this->_userResource->expects($this->once())->method('load')->with($this->anything(), 'key', 'api_key')->will($this->returnSelf());
     $model = $this->_createModel($this->_userResource);
     $result = $model->loadByKey('key');
     $this->assertInstanceOf('Mage_Webapi_Model_Acl_User', $result);
 }
Exemple #9
0
 /**
  * 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;
 }
 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');
 }
Exemple #11
0
 /**
  * @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();
 }
Exemple #12
0
 public function testSave()
 {
     $data = ['sample' => ['sampleData', 'link' => ['linkData']]];
     $this->product->expects($this->once())->method('getDownloadableData')->will($this->returnValue($data));
     $this->typeHandler->expects($this->once())->method('save')->with($this->product, $data);
     $this->target->save($this->product);
 }
 /**
  * @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));
     }
 }
 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);
 }
Exemple #15
0
 public function testGetProductId()
 {
     $productId = 1;
     $this->orderItemMock->expects($this->once())->method('getProductId')->willReturn($productId);
     $result = $this->item->getProductId($this->orderItemMock);
     $this->assertEquals($productId, $result);
 }
 /**
  * @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));
 }
 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());
 }
 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);
 }
 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)));
 }
Exemple #20
0
 /**
  * @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();
 }
 /**
  * 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);
 }
 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());
 }
Exemple #23
0
 /**
  * afterUpdateMview with disabled PageCache module
  */
 public function testAfterUpdateMviewPageCacheDisabled()
 {
     $this->moduleManager->expects($this->once())->method('isEnabled')->with($this->equalTo('Magento_PageCache'))->will($this->returnValue(false));
     $this->eventManagerMock->expects($this->never())->method('dispatch');
     $actualResult = $this->plugin->afterUpdateMview($this->subjectMock);
     $this->assertNull($actualResult);
 }
Exemple #24
0
 public function testGetPath()
 {
     $path = 'test_path';
     $this->sessionConfigMock->expects($this->once())->method('getCookiePath')->will($this->returnValue($path));
     $result = $this->model->getPath();
     $this->assertEquals($path, $result);
 }
Exemple #25
0
 /**
  * @runInSeparateProcess
  * @expectedException \RuntimeException
  */
 public function testRandomWithFailure()
 {
     $this->php = FunctionMocker::start($this, 'Chromabits\\Nucleus\\Support')->mockFunction('function_exists')->mockFunction('openssl_random_pseudo_bytes')->getMock();
     $this->php->expects($this->once())->method('function_exists')->will($this->returnValue(true));
     $this->php->expects($this->once())->method('openssl_random_pseudo_bytes')->will($this->returnValue(false));
     Str::random();
 }
 public function testSchedule()
 {
     $testIntegrationType = 'testIntegrationType';
     $testConnectorType = 'testConnectorType';
     $testId = 22;
     $integration = new Integration();
     $integration->setType($testIntegrationType);
     $integration->setEnabled(true);
     $ref = new \ReflectionProperty(get_class($integration), 'id');
     $ref->setAccessible(true);
     $ref->setValue($integration, $testId);
     $this->typesRegistry->addChannelType($testIntegrationType, new TestIntegrationType());
     $this->typesRegistry->addConnectorType($testConnectorType, $testIntegrationType, new TestTwoWayConnector());
     $that = $this;
     $uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock();
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow));
     $metadataFactory = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->getMock();
     $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue(new ClassMetadata('testEntity')));
     $this->em->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory));
     $uow->expects($this->once())->method('persist')->with($this->isInstanceOf('JMS\\JobQueueBundle\\Entity\\Job'))->will($this->returnCallback(function (Job $job) use($that, $testId, $testConnectorType) {
         $expectedArgs = ['--integration=' . $testId, sprintf('--connector=testConnectorType', $testConnectorType), '--params=a:0:{}'];
         $that->assertEquals($expectedArgs, $job->getArgs());
     }));
     $uow->expects($this->once())->method('computeChangeSet');
     $this->scheduler->schedule($integration, $testConnectorType, [], false);
 }
 /**
  * @dataProvider linkDataProvider
  * @test
  * @param \PHPUnit_Framework_MockObject_MockObject $categoryMock
  * @param \PHPUnit_Framework_MockObject_MockObject $filterMock
  * @param $type
  * @param $expected
  */
 public function testGetFilterByCategory(\PHPUnit_Framework_MockObject_MockObject $categoryMock, \PHPUnit_Framework_MockObject_MockObject $filterMock, $type, $expected)
 {
     $filterMock->method('isMultiSelectFilter')->willReturn($type);
     $this->filterRepository->expects($this->once())->method('findOneByCategories')->with($categoryMock)->willReturn($filterMock);
     $this->viewHelper->render(1, array(), 0, false, false, '', false, false, false, array(), null, $categoryMock);
     $this->assertSame($expected, $this->viewHelper->getAdditionalParams());
 }
 public function testFetchRates()
 {
     $currencyFromList = ['USD'];
     $currencyToList = ['EUR', 'UAH'];
     $responseBody = '{"base":"USD","date":"2015-10-07","rates":{"EUR":0.9022}}';
     $expectedCurrencyRateList = ['USD' => ['EUR' => 0.9022, 'UAH' => null]];
     $message = "We can't retrieve a rate from http://api.fixer.io/latest?base=USD&symbols=EUR,UAH for UAH.";
     /** @var \Magento\Directory\Model\Currency|\PHPUnit_Framework_MockObject_MockObject $currencyMock */
     $currencyMock = $this->getMockBuilder('Magento\\Directory\\Model\\Currency')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var \Magento\Framework\HTTP\ZendClient|\PHPUnit_Framework_MockObject_MockObject $currencyMock */
     $httpClientMock = $this->getMockBuilder('Magento\\Framework\\HTTP\\ZendClient')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var \Zend_Http_Response|\PHPUnit_Framework_MockObject_MockObject $currencyMock */
     $httpResponseMock = $this->getMockBuilder('Zend_Http_Response')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->currencyFactoryMock->expects($this->any())->method('create')->willReturn($currencyMock);
     $currencyMock->expects($this->once())->method('getConfigBaseCurrencies')->willReturn($currencyFromList);
     $currencyMock->expects($this->once())->method('getConfigAllowCurrencies')->willReturn($currencyToList);
     $this->httpClientFactoryMock->expects($this->any())->method('create')->willReturn($httpClientMock);
     $httpClientMock->expects($this->atLeastOnce())->method('setUri')->willReturnSelf();
     $httpClientMock->expects($this->atLeastOnce())->method('setConfig')->willReturnSelf();
     $httpClientMock->expects($this->atLeastOnce())->method('request')->willReturn($httpResponseMock);
     $httpResponseMock->expects($this->any())->method('getBody')->willReturn($responseBody);
     $this->assertEquals($expectedCurrencyRateList, $this->model->fetchRates());
     $messages = $this->model->getMessages();
     $this->assertNotEmpty($messages);
     $this->assertTrue(is_array($messages));
     $this->assertEquals($message, (string) $messages[0]);
 }
Exemple #29
0
 /**
  * @param mixed $class
  * @param array $arguments
  * @param string $expectedClassName
  * @dataProvider createDataProvider
  */
 public function testCreate($class, $arguments, $expectedClassName)
 {
     $createdModel = $this->getMock('Magento\\Sales\\Model\\Order\\Pdf\\Total\\DefaultTotal', array(), array(), (string) $class, false);
     $this->_objectManager->expects($this->once())->method('create')->with($expectedClassName, $arguments)->will($this->returnValue($createdModel));
     $actual = $this->_factory->create($class, $arguments);
     $this->assertSame($createdModel, $actual);
 }
Exemple #30
-1
 /**
  * @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);
 }