Asserts that a condition is true.
public static assertTrue ( boolean $condition, string $message = '' ) | ||
$condition | boolean | |
$message | string |
/** * Assert bestseller info in report: date, product name and qty. * * @param Bestsellers $bestsellers * @param OrderInjectable $order * @param string $date * @return void */ public function processAssert(Bestsellers $bestsellers, OrderInjectable $order, $date) { /** @var CatalogProductSimple $product */ $product = $order->getEntityId()['products'][0]; $filter = ['date' => date($date), 'product' => $product->getName(), 'price' => $product->getPrice(), 'orders' => $product->getCheckoutData()['qty']]; \PHPUnit_Framework_Assert::assertTrue($bestsellers->getGridBlock()->isRowVisible($filter, false), 'Bestseller does not present in report grid.'); }
/** * 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.'); }
/** * 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.'); }
public function testGetDirectory() { $dir = new FooDirectory($this->getMongoDB()); $model = $dir->create(); $directory = $model->getDirectory(); PHPUnit::assertTrue($directory instanceof FooDirectory); }
/** * 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."); }
/** * 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 video is absent 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::assertTrue(strpos($src, '/placeholder/') !== false, 'Product image is displayed on category view when it should not.'); }
/** * Assert customer availability in Customer Grid. * * @param Customer $customer * @param CustomerIndex $pageCustomerIndex * @param Customer $initialCustomer [optional] * @return void * * @SuppressWarnings(PHPMD.NPathComplexity) */ public function processAssert(Customer $customer, CustomerIndex $pageCustomerIndex, Customer $initialCustomer = null) { $data = $this->prepareData($customer, $initialCustomer); $filter = ['name' => $data[0], 'email' => $data[1]['email']]; $pageCustomerIndex->open(); \PHPUnit_Framework_Assert::assertTrue($pageCustomerIndex->getCustomerGridBlock()->isRowVisible($filter), 'Customer with ' . 'name \'' . $filter['name'] . '\', ' . 'email \'' . $filter['email'] . '\' ' . 'is absent in Customer grid.'); }
public function assertDestinationCorrect(ezcWebdavMemoryBackend $backend) { PHPUnit_Framework_Assert::assertTrue($backend->nodeExists('/other_collection/moved_resource.html')); $prop = $backend->getProperty('/other_collection/moved_resource.html', 'lockdiscovery'); PHPUnit_Framework_Assert::assertNotNull($prop, 'Lock discovery property not available on destination.'); PHPUnit_Framework_Assert::assertEquals(0, count($prop->activeLock), 'Active lock available on destination.'); }
/** * Check whether the attribute filter is displayed on the frontend in Layered navigation. * * @param CatalogCategoryView $catalogCategoryView * @param InjectableFixture $product * @param CatalogProductAttribute $attribute * @param CmsIndex $cmsIndex * @param FixtureFactory $fixtureFactory * @return void */ public function processAssert(CatalogCategoryView $catalogCategoryView, InjectableFixture $product, CatalogProductAttribute $attribute, CmsIndex $cmsIndex, FixtureFactory $fixtureFactory) { $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category_with_anchor', 'data' => ['category_ids' => ['presets' => null, 'category' => $product->getDataFieldConfig('category_ids')['source']->getCategories()[0]]]])->persist(); $cmsIndex->open()->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]); $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel(); \PHPUnit_Framework_Assert::assertTrue(in_array($label, $catalogCategoryView->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on category page.'); }
/** * Assert that product is displayed in related products section. * * @param Browser $browser * @param CatalogProductSimple $product * @param InjectableFixture[] $relatedProducts * @param CatalogProductView $catalogProductView * @return void */ public function processAssert(Browser $browser, CatalogProductSimple $product, array $relatedProducts, CatalogProductView $catalogProductView) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); foreach ($relatedProducts as $relatedProduct) { \PHPUnit_Framework_Assert::assertTrue($catalogProductView->getRelatedProductBlock()->getItemBlock($relatedProduct)->isVisible(), "Product {$relatedProduct->getName()} is absent in related products."); } }
/** * Assert that product attribute is global. * * @param CatalogProductAttribute $attribute * @param CatalogProductAttributeIndex $attributeIndexPage * @return void */ public function processAssert(CatalogProductAttribute $attribute, CatalogProductAttributeIndex $attributeIndexPage) { $attributeIndexPage->open(); $code = $attribute->getAttributeCode(); $filter = ['attribute_code' => $code, 'is_global' => $attribute->getIsGlobal()]; \PHPUnit_Framework_Assert::assertTrue($attributeIndexPage->getGrid()->isRowVisible($filter), "Attribute with attribute code '{$code}' isn't global."); }
/** * Assert Link block for downloadable product on front-end * * @param CatalogProductView $downloadableProductView * @param CatalogProductDownloadable $product * @param Browser $browser * @return void */ public function processAssert(CatalogProductView $downloadableProductView, CatalogProductDownloadable $product, Browser $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $linksBlock = $downloadableProductView->getDownloadableViewBlock()->getDownloadableLinksBlock(); $fields = $product->getData(); // Title for for Link block \PHPUnit_Framework_Assert::assertEquals($linksBlock->getTitleForLinkBlock(), $fields['downloadable_links']['title'], 'Title for for Link block for downloadable product on front-end is not correct.'); $this->sortDownloadableArray($fields['downloadable_links']['downloadable']['link']); foreach ($fields['downloadable_links']['downloadable']['link'] as $index => $link) { $index++; // Titles for each links // Links are displaying according to Sort Order \PHPUnit_Framework_Assert::assertEquals($linksBlock->getItemTitle($index), $link['title'], 'Link item ' . $index . ' with title "' . $link['title'] . '" is not visible.'); // If Links can be Purchase Separately, check-nob is presented near each link // If Links CANNOT be Purchase Separately, check-nob is not presented near each link if ($fields['downloadable_links']['links_purchased_separately'] == "Yes") { \PHPUnit_Framework_Assert::assertTrue($linksBlock->isVisibleItemCheckbox($index), 'Item ' . $index . ' link block CANNOT be Purchase Separately.'); // Price is equals passed according to fixture $link['price'] = sprintf('$%1.2f', $link['price']); \PHPUnit_Framework_Assert::assertEquals($linksBlock->getItemPrice($index), $link['price'], 'Link item ' . $index . ' price is not visible.'); } elseif ($fields['downloadable_links']['links_purchased_separately'] == "No") { \PHPUnit_Framework_Assert::assertFalse($linksBlock->isVisibleItemCheckbox($index), 'Item ' . $index . ' link block can be Purchase Separately.'); } } }
/** * Assert that order Id is present in search results * * @param Dashboard $dashboard * @param GlobalSearch $search * @return void */ public function processAssert(Dashboard $dashboard, GlobalSearch $search) { $order = $search->getDataFieldConfig('query')['source']->getEntity(); $orderId = "Order #" . $order->getId(); $isVisibleInResult = $dashboard->getAdminPanelHeader()->isSearchResultVisible($orderId); \PHPUnit_Framework_Assert::assertTrue($isVisibleInResult, 'Order Id ' . $order->getId() . ' is absent in search results'); }
/** * Flush cache storage and assert success message. * * @return void */ protected function flushCacheStorageWithAssert() { $this->cachePage->open(); $this->cachePage->getActionsBlock()->flushCacheStorage(); $this->cachePage->getModalBlock()->acceptAlert(); \PHPUnit_Framework_Assert::assertTrue($this->cachePage->getActionsBlock()->isStorageCacheFlushed(), 'Cache is not flushed.'); }
/** * Assert that product is present in products grid and can be found by sku, type, status and attribute set. * * @param FixtureInterface $product * @param CatalogProductIndex $productIndex * @return void */ public function processAssert(FixtureInterface $product, CatalogProductIndex $productIndex) { $this->product = $product; $productIndex->open(); $productIndex->getProductGrid()->resetFilter(); \PHPUnit_Framework_Assert::assertTrue($productIndex->getProductGrid()->isRowVisible($this->prepareFilter()), 'Product \'' . $this->product->getName() . '\' is absent in Products grid.'); }
/** * Assert that products' MAP has been applied before checkout. * * @param CatalogCategory $category * @param Customer $customer * @param Address $address * @param CatalogCategoryView $catalogCategoryView * @param CmsIndex $cmsIndex * @param CatalogProductView $catalogProductView * @param CheckoutCart $cart * @param CheckoutOnepage $checkoutOnePage * @param array $products * @return void */ public function processAssert(CatalogCategory $category, Customer $customer, Address $address, CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, CatalogProductView $catalogProductView, CheckoutCart $cart, CheckoutOnepage $checkoutOnePage, array $products) { for ($i = 0; $i < count($products); $i++) { $cart->getCartBlock()->clearShoppingCart(); $productName = $products[$i]->getName(); $cmsIndex->open(); $cmsIndex->getTopmenu()->selectCategory($category->getName()); // Check that price is not present on category page. $listProductBlock = $catalogCategoryView->getListProductBlock(); $productPriceBlock = $listProductBlock->getProductPriceBlock($productName); $productPriceBlock->clickForPrice(); \PHPUnit_Framework_Assert::assertFalse($productPriceBlock->getMapBlock()->isPriceVisible(), 'Price is present in MSRP dialog on category page.'); // Check that price is not present on product page. $listProductBlock->openProductViewPage($productName); \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getViewBlock()->getPriceBlock()->isRegularPriceVisible(), 'Price is present in View block on product page.'); // Check that price is not present on cart. $catalogProductView->getViewBlock()->addToCart($products[$i]); \PHPUnit_Framework_Assert::assertTrue($cart->getCartBlock()->getCartItem($products[$i])->isMsrpVisible(), "MSRP link is not visible in cart."); // Check that price is present on review block in onepage checkout page. $cart->getCartBlock()->getProceedToCheckoutBlock()->proceedToCheckout(); $checkoutMethodBlock = $checkoutOnePage->getLoginBlock(); $billingBlock = $checkoutOnePage->getBillingBlock(); $paymentMethodBlock = $checkoutOnePage->getPaymentMethodsBlock(); $shippingBlock = $checkoutOnePage->getShippingMethodBlock(); $checkoutMethodBlock->guestCheckout(); $checkoutMethodBlock->clickContinue(); $billingBlock->fillBilling($address, $customer); $billingBlock->clickContinue(); $shippingBlock->selectShippingMethod(['shipping_service' => 'Flat Rate', 'shipping_method' => 'Fixed']); $shippingBlock->clickContinue(); $paymentMethodBlock->selectPaymentMethod(['method' => 'checkmo']); $paymentMethodBlock->clickContinue(); \PHPUnit_Framework_Assert::assertEquals(number_format($products[$i]->getPrice(), 2), $checkoutOnePage->getReviewBlock()->getTotalBlock()->getData('subtotal'), "Subtotal in checkout one page for {$productName} is not equal to expected."); } }
/** * Check whether attribute is displayed in the advanced search form on the frontend. * * @param CatalogProductAttribute $attribute * @param CatalogsearchAdvanced $advancedSearch * @return void */ public function processAssert(CatalogProductAttribute $attribute, CatalogsearchAdvanced $advancedSearch) { $advancedSearch->open(); $formLabels = $advancedSearch->getForm()->getFormlabels(); $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel(); \PHPUnit_Framework_Assert::assertTrue(in_array($label, $formLabels), 'Attribute is absent on advanced search form.'); }
/** * 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."); }
/** * Verify item product data. * * @param InjectableFixture $product * @param int|null $expectedQty * @return void */ protected function verifyItemProduct(InjectableFixture $product, $expectedQty) { \PHPUnit_Framework_Assert::assertTrue($this->wishlistIndex->getItemsBlock()->getItemProductBlock($product)->isVisible(), 'Product "' . $product->getName() . '" in custom wishlist doesn\'t visible.'); if ($expectedQty !== null) { \PHPUnit_Framework_Assert::assertEquals($expectedQty, $this->wishlistIndex->getItemsBlock()->getItemProductBlock($product)->getData()['qty'], 'Actual quantity of "' . $product->getName() . '" in custom wishlist doesn\'t match to expected.'); } }
/** * @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); }
/** * Asserts that Default Billing Address and Default Shipping Address equal to data from fixture. * * @param CustomerAccountIndex $customerAccountIndex * @param CustomerAccountAddress $customerAccountAddress * @param Address $address * @return void */ public function processAssert(CustomerAccountIndex $customerAccountIndex, CustomerAccountAddress $customerAccountAddress, Address $address) { $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book'); $addressRenderer = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $address, 'type' => 'html']); $addressToVerify = $addressRenderer->render(); \PHPUnit_Framework_Assert::assertTrue($addressToVerify == $customerAccountAddress->getDefaultAddressBlock()->getDefaultBillingAddress() && $addressToVerify == $customerAccountAddress->getDefaultAddressBlock()->getDefaultShippingAddress(), 'Customer default address on address book tab is not matching the fixture.'); }
/** * 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."); }
/** * Asserts that Asserts that 'Additional Address Entries' contains expected message * * @param CustomerAccountIndex $customerAccountIndex * @return void */ public function processAssert(CustomerAccountIndex $customerAccountIndex) { $customerAccountIndex->open(); $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Address Book'); $actualText = $customerAccountIndex->getAdditionalAddressBlock()->getBlockText(); \PHPUnit_Framework_Assert::assertTrue(self::EXPECTED_MESSAGE == $actualText, 'Expected text is absent in Additional Address block.'); }
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)); }
/** * Assert that displayed product bundle items data on product page equals passed from fixture preset * * @param CatalogProductView $catalogProductView * @param CatalogProductBundle $product * @param Browser $browser * @return void */ public function processAssert(CatalogProductView $catalogProductView, CatalogProductBundle $product, Browser $browser) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->clickCustomize(); $result = $this->displayedBundleBlock($catalogProductView, $product); \PHPUnit_Framework_Assert::assertTrue(empty($result), $result); }
/** * 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 products are present in shopping cart. * * @param CheckoutCart $checkoutCart * @param array $products * @return void */ public function processAssert(CheckoutCart $checkoutCart, array $products) { $checkoutCart->open(); foreach ($products as $product) { \PHPUnit_Framework_Assert::assertTrue($checkoutCart->getCartBlock()->getCartItem($product)->isVisible(), "Product '{$product->getName()}' is absent in shopping cart."); } }
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); }
/** * @Given the system should have the following internet profiles: * * @param PyStringNode $body * */ public function theSystemShouldHaveTheFollowingInternetProfiles(PyStringNode $body) { /** @var CollectProfilesTestWorker $collectProfilesTestWorker */ $collectProfilesTestWorker = $this->kernel->getContainer()->get('muchacuba.internet.collect_profiles_test_worker'); Assert::assertTrue((new SimpleFactory())->createMatcher()->match(iterator_to_array($collectProfilesTestWorker->collect()), (array) json_decode($body->getRaw(), true))); $this->rootContext->ignoreState('Muchacuba\\Internet\\Profile'); }