本文整理汇总了PHP中PHPUnit_Framework_Assert类的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Assert类的具体用法?PHP PHPUnit_Framework_Assert怎么用?PHP PHPUnit_Framework_Assert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPUnit_Framework_Assert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAssert
/**
* 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.');
}
示例2: assertErrorsAreTriggered
/**
* @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);
}
}
示例3: processAssert
/**
* 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);
}
示例4: check
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);
}
示例5: it_is_serializable
function it_is_serializable()
{
$that = new PlayerCard();
$that->setTitle('Lorem ipsum');
$that = unserialize(serialize($that));
\PHPUnit_Framework_Assert::assertEquals('Lorem ipsum', $that->getTitle());
}
示例6: processAssert
/**
* 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));
}
}
}
示例7: processAssert
/**
* 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.');
}
示例8: processAssert
/**
* 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);
}
示例9: processAssert
/**
* 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);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:AbstractAssertTaxCalculationAfterCheckoutDownloadable.php
示例10: processAssert
/**
* 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.");
}
示例11: processAssert
/**
* 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.');
}
示例12: processAssert
/**
* 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.");
}
示例13: processAssert
/**
* 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.');
}
示例14: processAssert
/**
* 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.");
}
示例15: processAssert
/**
* 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.');
}