Author: Sebastian Bergmann (sb@sebastian-bergmann.de)
 /**
  * Verify incorrect credentials message while login to admin
  *
  * @param AdminAuthLogin $adminAuth
  * @param User $customAdmin
  * @return void
  */
 public function processAssert(AdminAuthLogin $adminAuth, User $customAdmin)
 {
     $adminAuth->open();
     $adminAuth->getLoginBlock()->fill($customAdmin);
     $adminAuth->getLoginBlock()->submit();
     \PHPUnit_Framework_Assert::assertEquals(self::INVALID_CREDENTIALS_MESSAGE, $adminAuth->getMessagesBlock()->getErrorMessages(), 'Message "' . self::INVALID_CREDENTIALS_MESSAGE . '" is not visible.');
 }
 /**
  * Assert that after deleting product success message.
  *
  * @param FixtureInterface|FixtureInterface[] $product
  * @param CatalogProductIndex $productPage
  * @return void
  */
 public function processAssert($product, CatalogProductIndex $productPage)
 {
     $products = is_array($product) ? $product : [$product];
     $deleteMessage = sprintf(self::SUCCESS_DELETE_MESSAGE, count($products));
     $actualMessage = $productPage->getMessagesBlock()->getSuccessMessage();
     \PHPUnit_Framework_Assert::assertEquals($deleteMessage, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . $deleteMessage . "\nActual: " . $actualMessage);
 }
Example #3
0
 public function check(PHPUnit_Framework_Assert $test, $data, $ignore_db_info = true)
 {
     $cache_data = $this->data;
     if ($ignore_db_info) {
         unset($cache_data['mssqlodbc_version']);
         unset($cache_data['mssql_version']);
         unset($cache_data['mysql_version']);
         unset($cache_data['mysqli_version']);
         unset($cache_data['pgsql_version']);
         unset($cache_data['sqlite_version']);
     }
     $test->assertEquals($data, $cache_data);
 }
 /**
  * @Given /^the image at index (\d+) "([^"]*)" is "([^"]*)"$/
  */
 public function theImageAtIndexIs($componentIndex, $componentKey, $componentValue)
 {
     $component = self::$appleNewsObject->components[$componentIndex];
     Assert::assertEquals('photo', $component->components[0]->role);
     Assert::assertTrue(isset($component->components[0]->caption));
     Assert::assertEquals($componentValue, $component->components[0]->caption);
 }
 /**
  * Assert that required tax rate is present in "Tax Rule Information" on tax rule creation page.
  *
  * @param TaxRuleIndex $taxRuleIndex
  * @param TaxRuleNew $taxRuleNew
  * @param TaxRate $taxRate
  * @return void
  */
 public function processAssert(TaxRuleIndex $taxRuleIndex, TaxRuleNew $taxRuleNew, TaxRate $taxRate)
 {
     $taxRateCode = $taxRate->getCode();
     $taxRuleIndex->open();
     $taxRuleIndex->getGridPageActions()->addNew();
     \PHPUnit_Framework_Assert::assertTrue($taxRuleNew->getTaxRuleForm()->isTaxRateAvailable($taxRateCode), "{$taxRateCode} is not present in Tax Rates multiselect on tax rule creation page.");
 }
 /**
  * Assert that success save message is appeared on the Integrations page
  *
  * @param IntegrationIndex $integrationIndexPage
  * @param Integration $integration
  * @param Integration|null $initialIntegration
  * @return void
  */
 public function processAssert(IntegrationIndex $integrationIndexPage, Integration $integration, Integration $initialIntegration = null)
 {
     $name = $initialIntegration !== null && !$integration->hasData('name') ? $initialIntegration->getName() : $integration->getName();
     $expectedMessage = sprintf(self::SUCCESS_SAVE_MESSAGE, $name);
     $actualMessage = $integrationIndexPage->getMessagesBlock()->getSuccessMessage();
     \PHPUnit_Framework_Assert::assertEquals($expectedMessage, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . $expectedMessage . "\nActual: " . $actualMessage);
 }
 /**
  * Assert that products are displayed in up-sell section.
  *
  * @param Browser $browser
  * @param FixtureInterface $product
  * @param array $upSellProducts
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(Browser $browser, FixtureInterface $product, array $upSellProducts, CatalogProductView $catalogProductView)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     foreach ($upSellProducts as $upSellProduct) {
         \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getUpsellBlock()->getItemBlock($upSellProduct)->isVisible(), "Product {$upSellProduct->getName()} is absent in up-sells products.");
     }
 }
 /**
  * Assert that prices on order review and customer order pages are equal to specified in dataset.
  *
  * @param array $prices
  * @param InjectableFixture $product
  * @param CheckoutCart $checkoutCart
  * @param CheckoutOnepage $checkoutOnepage
  * @param CheckoutOnepageSuccess $checkoutOnepageSuccess
  * @param CustomerOrderView $customerOrderView
  * @return void
  */
 public function processAssert(array $prices, InjectableFixture $product, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, CustomerOrderView $customerOrderView)
 {
     $this->checkoutOnepage = $checkoutOnepage;
     $this->customerOrderView = $customerOrderView;
     $checkoutCart->getProceedToCheckoutBlock()->proceedToCheckout();
     $checkoutOnepage->getBillingBlock()->clickContinue();
     $checkoutOnepage->getPaymentMethodsBlock()->selectPaymentMethod(['method' => 'check_money_order']);
     $checkoutOnepage->getPaymentMethodsBlock()->clickContinue();
     $actualPrices = [];
     $actualPrices = $this->getReviewPrices($actualPrices, $product);
     $actualPrices = $this->getReviewTotals($actualPrices);
     $prices = $this->preparePrices($prices);
     //Order review prices verification
     $message = 'Prices on order review should be equal to defined in dataset.';
     \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message);
     $checkoutOnepage->getReviewBlock()->placeOrder();
     $checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId();
     $checkoutOnepageSuccess->getSuccessBlock()->openOrder();
     $actualPrices = [];
     $actualPrices = $this->getOrderPrices($actualPrices, $product);
     $actualPrices = $this->getOrderTotals($actualPrices);
     //Frontend order prices verification
     $message = 'Prices on order view page should be equal to defined in dataset.';
     \PHPUnit_Framework_Assert::assertEquals($prices, $actualPrices, $message);
 }
 /**
  * Assert that New Store Group visible on StoreView Form in Store dropdown.
  *
  * @param StoreIndex $storeIndex
  * @param StoreNew $storeNew
  * @param StoreGroup $storeGroup
  * @return void
  */
 public function processAssert(StoreIndex $storeIndex, StoreNew $storeNew, StoreGroup $storeGroup)
 {
     $storeIndex->open();
     $storeGroupName = $storeGroup->getName();
     $storeIndex->getGridPageActions()->addStoreView();
     \PHPUnit_Framework_Assert::assertTrue($storeNew->getStoreForm()->isStoreVisible($storeGroupName), "Store Group '{$storeGroupName}' is not present on StoreView Form in Store dropdown.");
 }
 /**
  * Assert tax rule availability in Tax Rate grid.
  *
  * @param TaxRateIndex $taxRateIndexPage
  * @param TaxRate $taxRate
  * @return void
  */
 public function processAssert(TaxRateIndex $taxRateIndexPage, TaxRate $taxRate)
 {
     $data = $taxRate->getData();
     $filter = ['code' => $data['code'], 'tax_country_id' => $data['tax_country_id'], 'tax_postcode' => $data['zip_is_range'] === 'No' ? $data['tax_postcode'] : $data['zip_from'] . '-' . $data['zip_to']];
     $taxRateIndexPage->open();
     \PHPUnit_Framework_Assert::assertTrue($taxRateIndexPage->getTaxRatesGrid()->isRowVisible($filter), "Tax Rate {$filter['code']} is absent in Tax Rate grid.");
 }
 /**
  * Assert that product is present in grid on customer's wish list tab with configure option and qty
  *
  * @param CustomerIndexEdit $customerIndexEdit
  * @param FixtureInterface $product
  * @return void
  */
 public function processAssert(CustomerIndexEdit $customerIndexEdit, FixtureInterface $product)
 {
     $filter = $this->prepareFilter($product);
     /** @var Grid $wishlistGrid */
     $wishlistGrid = $customerIndexEdit->getCustomerForm()->getTabElement('wishlist')->getSearchGridBlock();
     \PHPUnit_Framework_Assert::assertTrue($wishlistGrid->isRowVisible($filter, true, false), 'Product ' . $product->getName() . ' is absent in grid with configure option.');
 }
 /**
  * Assert that video is displayed on category page on Store front.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param InjectableFixture $initialProduct
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, InjectableFixture $initialProduct)
 {
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($initialProduct->getCategoryIds()[0]);
     $src = $catalogCategoryView->getListProductBlock()->getProductItem($initialProduct)->getBaseImageSource();
     \PHPUnit_Framework_Assert::assertFalse(strpos($src, '/placeholder/') !== false, 'Video preview image is not displayed on category view when it should.');
 }
 /**
  * Assert that after mass update successful message appears.
  *
  * @param CatalogProductIndex $productGrid
  * @param array $products
  * @return void
  */
 public function processAssert(CatalogProductIndex $productGrid, $products = [])
 {
     $countProducts = count($products) ? count($products) : 1;
     $expectedMessage = sprintf(self::SUCCESS_MESSAGE, $countProducts);
     $actualMessage = $productGrid->getMessagesBlock()->getSuccessMessages();
     \PHPUnit_Framework_Assert::assertEquals($expectedMessage, $actualMessage, 'Wrong success message is displayed.');
 }
 /**
  * Assert that 'Button name' button is absent order page.
  *
  * @param SalesOrderView $salesOrderView
  * @param SalesOrderIndex $orderIndex
  * @param Order $order
  * @param string|null $orderId
  * @return void
  */
 public function processAssert(SalesOrderView $salesOrderView, SalesOrderIndex $orderIndex, Order $order = null, $orderId = null)
 {
     $orderIndex->open();
     $orderId = $orderId == null ? $order->getId() : $orderId;
     $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
     \PHPUnit_Framework_Assert::assertFalse($salesOrderView->getPageActions()->isActionButtonVisible($this->buttonName), "'{$this->buttonName}' button is present on order view page.");
 }
 /**
  * Assert that the category cannot be accessed from the navigation bar in the frontend
  *
  * @param CmsIndex $cmsIndex
  * @param Category $category
  * @param BrowserInterface $browser
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Category $category, BrowserInterface $browser)
 {
     $cmsIndex->open();
     \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), 'Category can be accessed from the navigation bar in the frontend.');
     $browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html');
     \PHPUnit_Framework_Assert::assertEquals(self::NOT_FOUND_MESSAGE, $cmsIndex->getTitleBlock()->getTitle(), 'Wrong page is displayed.');
 }
 /**
  * Assert that displayed category data on category page equals to passed from fixture
  *
  * @param CatalogCategory $category
  * @param CatalogCategory $initialCategory
  * @param FixtureFactory $fixtureFactory
  * @param CatalogCategoryView $categoryView
  * @param Browser $browser
  * @return void
  */
 public function processAssert(CatalogCategory $category, CatalogCategory $initialCategory, FixtureFactory $fixtureFactory, CatalogCategoryView $categoryView, Browser $browser)
 {
     $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'default', 'data' => ['category_ids' => ['category' => $initialCategory]]]);
     $categoryData = array_merge($initialCategory->getData(), $category->getData());
     $product->persist();
     $url = $_ENV['app_frontend_url'] . strtolower($category->getUrlKey()) . '.html';
     $browser->open($url);
     \PHPUnit_Framework_Assert::assertEquals($url, $browser->getUrl(), 'Wrong page URL.' . "\nExpected: " . $url . "\nActual: " . $browser->getUrl());
     if (isset($categoryData['name'])) {
         $title = $categoryView->getTitleBlock()->getTitle();
         \PHPUnit_Framework_Assert::assertEquals($categoryData['name'], $title, 'Wrong page title.' . "\nExpected: " . $categoryData['name'] . "\nActual: " . $title);
     }
     if (isset($categoryData['description'])) {
         $description = $categoryView->getViewBlock()->getDescription();
         \PHPUnit_Framework_Assert::assertEquals($categoryData['description'], $description, 'Wrong category description.' . "\nExpected: " . $categoryData['description'] . "\nActual: " . $description);
     }
     if (isset($categoryData['default_sort_by'])) {
         $sortBy = strtolower($categoryData['default_sort_by']);
         $sortType = $categoryView->getTopToolbar()->getSelectSortType();
         \PHPUnit_Framework_Assert::assertEquals($sortBy, $sortType, 'Wrong sorting type.' . "\nExpected: " . $sortBy . "\nActual: " . $sortType);
     }
     if (isset($categoryData['available_sort_by'])) {
         $availableSortType = array_filter($categoryData['available_sort_by'], function (&$value) {
             return $value !== '-' && ucfirst($value);
         });
         if ($availableSortType) {
             $availableSortType = array_values($availableSortType);
             $availableSortTypeOnPage = $categoryView->getTopToolbar()->getSortType();
             \PHPUnit_Framework_Assert::assertEquals($availableSortType, $availableSortTypeOnPage, 'Wrong available sorting type.' . "\nExpected: " . implode(PHP_EOL, $availableSortType) . "\nActual: " . implode(PHP_EOL, $availableSortTypeOnPage));
         }
     }
 }
 /**
  * Assert that after save a search term on edit term search page displays:
  *  - correct Search Query field passed from fixture
  *  - correct Store
  *  - correct Number of results
  *  - correct Number of Uses
  *  - correct Synonym For
  *  - correct Redirect URL
  *  - correct Display in Suggested Terms
  *
  * @param CatalogSearchIndex $indexPage
  * @param CatalogSearchEdit $editPage
  * @param CatalogSearchQuery $searchTerm
  * @return void
  */
 public function processAssert(CatalogSearchIndex $indexPage, CatalogSearchEdit $editPage, CatalogSearchQuery $searchTerm)
 {
     $indexPage->open()->getGrid()->searchAndOpen(['search_query' => $searchTerm->getQueryText()]);
     $formData = $editPage->getForm()->getData($searchTerm);
     $fixtureData = $searchTerm->getData();
     \PHPUnit_Framework_Assert::assertEquals($formData, $fixtureData, 'This form "Search Term" does not match the fixture data.');
 }
 /**
  * Assert that created gift registry type can be found on frontend.
  *
  * @param Customer $customer
  * @param GiftRegistryType $giftRegistryType
  * @param CustomerAccountIndex $customerAccountIndex
  * @param GiftRegistryIndex $giftRegistryIndex
  * @param GiftRegistryAddSelect $giftRegistryAddSelect
  * @return void
  */
 public function processAssert(Customer $customer, GiftRegistryType $giftRegistryType, CustomerAccountIndex $customerAccountIndex, GiftRegistryIndex $giftRegistryIndex, GiftRegistryAddSelect $giftRegistryAddSelect)
 {
     $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $customerAccountIndex->getAccountNavigationBlock()->openNavigationItem("Gift Registry");
     $giftRegistryIndex->getGiftRegistryList()->addNew();
     \PHPUnit_Framework_Assert::assertTrue($giftRegistryAddSelect->getGiftRegistryEditForm()->isGiftRegistryVisible($giftRegistryType), "Gift registry '{$giftRegistryType->getLabel()}' is not present on frontend.");
 }
Example #19
0
 function it_is_serializable()
 {
     $that = new PlayerCard();
     $that->setTitle('Lorem ipsum');
     $that = unserialize(serialize($that));
     \PHPUnit_Framework_Assert::assertEquals('Lorem ipsum', $that->getTitle());
 }
Example #20
0
 public function testUtils()
 {
     // public key from WIF
     PHPUnit::assertEquals('03f05b88087b2392611d0eb388f11543b02b21d12c18aba21699e73e97a61fee15', BitcoinKeyUtils::publicKeyFromWIF('L2KB5RqtHwLKrNaVuxQCiNs549vbp4oy7FTF2zs2GChLXXnXyMee'));
     $caught_error = false;
     try {
         BitcoinKeyUtils::publicKeyFromWIF('BADWIF');
     } catch (Exception $e) {
         $caught_error = true;
     }
     PHPUnit::assertTrue($caught_error);
     // address from WIF
     PHPUnit::assertEquals('1NjZ3zsBySHtCWX3NtPFfmUXEwx7XeG82H', BitcoinKeyUtils::addressFromWIF('L2KB5RqtHwLKrNaVuxQCiNs549vbp4oy7FTF2zs2GChLXXnXyMee'));
     $caught_error = false;
     try {
         BitcoinKeyUtils::addressFromWIF('BADWIF');
     } catch (Exception $e) {
         $caught_error = true;
     }
     PHPUnit::assertTrue($caught_error);
     $generator = $this->getGenerator();
     $private_key = $generator->privateKey('mytoken1');
     PHPUnit::assertEquals('034fba8396613ae90defdc45e2e924a4bda2e1b94d653d4d28111523cc57ccb8d7', BitcoinKeyUtils::publicKeyFromPrivateKey($private_key)->getHex());
     PHPUnit::assertEquals('L4iQRBZz1XuqvE6qyfQZAn6AtiudyT9dnQTvnHU5n3TQ9G45sPJ3', BitcoinKeyUtils::WIFFromPrivateKey($private_key));
 }
 public function testAddBuilderPass()
 {
     $builderPass = $this->getMock('Certificationy\\Component\\Certy\\Builder\\BuilderPassInterface');
     $builder = new Builder();
     $builder->addBuilderPass($builderPass);
     $this->assertEquals([$builderPass], \PHPUnit_Framework_Assert::readAttribute($builder, 'builderPass'));
 }
Example #22
0
 public function testExecuteJobSuccess()
 {
     $configuration = array('test' => true);
     $this->entityManager->expects($this->once())->method('beginTransaction');
     $this->entityManager->expects($this->never())->method('rollback');
     $this->entityManager->expects($this->once())->method('commit');
     $this->batchJobManager->expects($this->at(0))->method('persist')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobInstance'));
     $this->batchJobManager->expects($this->at(1))->method('persist')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobExecution'));
     $this->batchJobManager->expects($this->at(2))->method('flush')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobInstance'));
     $this->batchJobManager->expects($this->at(3))->method('flush')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobExecution'));
     $context = $this->getMockBuilder('Oro\\Bundle\\ImportExportBundle\\Context\\ContextInterface')->getMockForAbstractClass();
     $stepExecution = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Entity\\StepExecution')->disableOriginalConstructor()->getMock();
     $stepExecution->expects($this->any())->method('getFailureExceptions')->will($this->returnValue(array()));
     $this->contextRegistry->expects($this->once())->method('getByStepExecution')->with($stepExecution)->will($this->returnValue($context));
     $job = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Job\\JobInterface')->getMock();
     $job->expects($this->once())->method('execute')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobExecution'))->will($this->returnCallback(function (JobExecution $jobExecution) use($configuration, $stepExecution) {
         \PHPUnit_Framework_Assert::assertEquals('import.test', $jobExecution->getJobInstance()->getLabel());
         \PHPUnit_Framework_Assert::assertEquals($configuration, $jobExecution->getJobInstance()->getRawConfiguration());
         $jobExecution->setStatus(new BatchStatus(BatchStatus::COMPLETED));
         $jobExecution->addStepExecution($stepExecution);
     }));
     $this->batchJobRegistry->expects($this->once())->method('getJob')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobInstance'))->will($this->returnValue($job));
     $result = $this->executor->executeJob('import', 'test', $configuration);
     $this->assertInstanceOf('Oro\\Bundle\\ImportExportBundle\\Job\\JobResult', $result);
     $this->assertTrue($result->isSuccessful());
     $this->assertEquals($context, $result->getContext());
 }
Example #23
0
 public static function requestMethod(Test $instance, $before, $after)
 {
     $instance->server('request_method', $before);
     PHPUnit_Framework_Assert::assertTrue($instance->curl->response === $before);
     $instance->server('request_method', $after);
     PHPUnit_Framework_Assert::assertTrue($instance->curl->response === $after);
 }
 /**
  * Assert that created CMS page displays with error message on unassigned store views on frontend.
  *
  * @param CmsPage $cms
  * @param FrontendCmsPage $frontendCmsPage
  * @param Browser $browser
  * @param CmsIndex $cmsIndex
  * @param string|null $notFoundMessage
  * @return void
  */
 public function processAssert(CmsPage $cms, FrontendCmsPage $frontendCmsPage, Browser $browser, CmsIndex $cmsIndex, $notFoundMessage = null)
 {
     $browser->open($_ENV['app_frontend_url'] . $cms->getIdentifier());
     $notFoundMessage = $notFoundMessage !== null ? $notFoundMessage : self::ERROR_MESSAGE;
     $cmsIndex->getHeaderBlock()->selectStore('Default Store View');
     \PHPUnit_Framework_Assert::assertContains($notFoundMessage, $frontendCmsPage->getCmsPageContentBlock()->getPageContent(), 'Wrong page content is displayed.');
 }
Example #25
0
 /**
  * Assert that product is not displayed in up-sell section
  *
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $product
  * @param InjectableFixture[] $relatedProducts
  * @param CatalogProductView $catalogProductView
  * @return void
  */
 public function processAssert(BrowserInterface $browser, CatalogProductSimple $product, array $relatedProducts, CatalogProductView $catalogProductView)
 {
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     foreach ($relatedProducts as $relatedProduct) {
         \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getUpsellBlock()->isUpsellProductVisible($relatedProduct->getName()), 'Product \'' . $relatedProduct->getName() . '\' is exist in up-sells products.');
     }
 }
 public function testXCPDClient()
 {
     $asset_info = $this->sampleLTBCoinAssetInfo();
     $cache = $this->app->make('Tokenly\\CounterpartyAssetInfoCache\\Cache');
     PHPUnit::assertEquals($asset_info, $cache->get('LTBCOIN'));
     PHPUnit::assertEquals($asset_info, $cache->getFromCache('LTBCOIN'));
 }
 /**
  * Assert that apache redirect works by opening category page and asserting index.php in its url.
  *
  * @param CatalogCategory $category
  * @param CmsIndex $homePage
  * @param BrowserInterface $browser
  */
 public function processAssert(CatalogCategory $category, CmsIndex $homePage, BrowserInterface $browser)
 {
     $category->persist();
     $homePage->open();
     $homePage->getTopmenu()->selectCategory($category->getName());
     \PHPUnit_Framework_Assert::assertTrue(strpos($browser->getUrl(), 'index.php') === false, 'Apache redirect for category does not work.');
 }
Example #28
0
 /**
  * @param int      $expectedType     Expected triggered error type (pass one of PHP's E_* constants)
  * @param string[] $expectedMessages Expected error messages
  * @param callable $testCode         A callable that is expected to trigger the error messages
  */
 public static function assertErrorsAreTriggered($expectedType, $expectedMessages, $testCode)
 {
     if (!is_callable($testCode)) {
         throw new \InvalidArgumentException(sprintf('The code to be tested must be a valid callable ("%s" given).', gettype($testCode)));
     }
     $e = null;
     $triggeredMessages = array();
     try {
         $prevHandler = set_error_handler(function ($type, $message, $file, $line, $context) use($expectedType, &$triggeredMessages, &$prevHandler) {
             if ($expectedType !== $type) {
                 return null !== $prevHandler && call_user_func($prevHandler, $type, $message, $file, $line, $context);
             }
             $triggeredMessages[] = $message;
         });
         call_user_func($testCode);
     } catch (\Exception $e) {
     } catch (\Throwable $e) {
     }
     restore_error_handler();
     if (null !== $e) {
         throw $e;
     }
     \PHPUnit_Framework_Assert::assertCount(count($expectedMessages), $triggeredMessages);
     foreach ($triggeredMessages as $i => $message) {
         \PHPUnit_Framework_Assert::assertContains($expectedMessages[$i], $message);
     }
 }
Example #29
0
 /**
  * Assert that data at the form corresponds to the fixture data
  *
  * @param SystemVariable $customVariable
  * @param SystemVariableIndex $systemVariableIndex
  * @param SystemVariableNew $systemVariableNew
  * @param Store $storeOrigin
  * @param SystemVariable $customVariableOrigin
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function processAssert(SystemVariable $customVariable, SystemVariableIndex $systemVariableIndex, SystemVariableNew $systemVariableNew, Store $storeOrigin = null, SystemVariable $customVariableOrigin = null)
 {
     // Prepare data
     $data = $customVariableOrigin === null ? $customVariable->getData() : array_merge($customVariableOrigin->getData(), $customVariable->getData());
     if ($customVariableOrigin !== null) {
         $dataOrigin = $data;
         $dataOrigin['html_value'] = $customVariableOrigin->getHtmlValue();
         $dataOrigin['plain_value'] = $customVariableOrigin->getPlainValue();
     } else {
         $dataOrigin = $data;
     }
     if ($data['html_value'] == '') {
         $data['html_value'] = $customVariableOrigin->getHtmlValue();
         $data['use_default_value'] = 'Yes';
     }
     $data['plain_value'] = $data['plain_value'] == '' ? $customVariableOrigin->getPlainValue() : $data['plain_value'];
     // Perform assert
     $systemVariableIndex->open();
     $systemVariableIndex->getSystemVariableGrid()->searchAndOpen(['code' => $data['code']]);
     $formData = $systemVariableNew->getSystemVariableForm()->getData($customVariable);
     $errors = $this->verifyData($dataOrigin, $formData);
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
     if ($storeOrigin !== null) {
         $systemVariableNew->getFormPageActions()->selectStoreView($storeOrigin->getName());
         $formData = $systemVariableNew->getSystemVariableForm()->getData($customVariable);
         $errors = $this->verifyData($data, $formData);
         \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
     }
 }
 /**
  * Assert that newsletter preview opened in new window and template content correct
  *
  * @param BrowserInterface $browser
  * @param TemplatePreview $templatePreview
  * @param Template $newsletter
  * @return void
  */
 public function processAssert(BrowserInterface $browser, TemplatePreview $templatePreview, Template $newsletter)
 {
     $browser->selectWindow();
     $content = $templatePreview->getContent()->getPageContent();
     $browser->closeWindow();
     \PHPUnit_Framework_Assert::assertEquals($newsletter->getText(), $content, 'Template content not correct information.');
 }