本文整理汇总了PHP中PHPUnit_Framework_Assert::assertContains方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Assert::assertContains方法的具体用法?PHP PHPUnit_Framework_Assert::assertContains怎么用?PHP PHPUnit_Framework_Assert::assertContains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Assert
的用法示例。
在下文中一共展示了PHPUnit_Framework_Assert::assertContains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: processAssert
/**
* Assert that comment about authorized amount exist in Comments History section on order page in backend.
*
* @param SalesOrderView $salesOrderView
* @param OrderIndex $salesOrder
* @param string $orderId
* @param array $prices
* @return void
*/
public function processAssert(SalesOrderView $salesOrderView, OrderIndex $salesOrder, $orderId, array $prices)
{
$salesOrder->open();
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
$actualAuthorizedAmount = $salesOrderView->getOrderHistoryBlock()->getCommentsHistory();
\PHPUnit_Framework_Assert::assertContains(self::AUTHORIZED_AMOUNT . $prices['grandTotal'], $actualAuthorizedAmount, 'Incorrect authorized amount value for the order #' . $orderId);
}
示例3: processAssert
/**
* 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.');
}
示例4: assertTableRowContains
/**
* @Then /^I should see "(?P<text>[^"]*)" in (?P<tableName>[\w\d\-]+) table row with "(?P<row>[^"]*)"$/
* @Then /^I should see "(?P<text>[^"]*)" in (?P<row>\d+)(st|nd|rd|th)? (?P<tableName>[\w\d\-]+) table row$/
*/
public function assertTableRowContains($text, $row, $tableName)
{
$table = $this->findTable($tableName);
$row = is_numeric($row) ? $table->getRow($row - 1) : $table->findRow($row);
Assert::assertNotEmpty($row, "Couldn't find row {$row} in table: " . PHP_EOL . $table->dump());
Assert::assertContains($text, $row, "Couldn't find {$text} in row " . $table->dumpRows(array($row)));
}
示例5: iShouldSee
/**
* @Then /^I should see "([^"]*)"$/
*/
public function iShouldSee($match)
{
if ($this->response instanceof \Exception) {
throw $this->response;
}
PHPUnit_Framework_Assert::assertContains($match, $this->response->getContent());
}
示例6: iOpenDialog
/**
* @Given /^I open "([^"]*)" dialog$/
*/
public function iOpenDialog($dialog)
{
$client = self::getClientInstance();
$route = 'oro_' . str_replace(' ', '_', strtolower($dialog));
$client->request('GET', $this->getUrl($route));
WebTestCase::assertHtmlResponseStatusCodeEquals($client->getResponse(), 200);
PHPUnit_Framework_Assert::assertContains('Create User - Users - User Management - System', $client->getCrawler()->html());
}
示例7: processAssert
/**
* Assert that success message is displayed after Catalog Price Rule saved
*
* @param CatalogRuleIndex $pageCatalogRuleIndex
* @return void
*/
public function processAssert(CatalogRuleIndex $pageCatalogRuleIndex)
{
$actualMessages = $pageCatalogRuleIndex->getMessagesBlock()->getSuccessMessages();
if (!is_array($actualMessages)) {
$actualMessages = [$actualMessages];
}
\PHPUnit_Framework_Assert::assertContains(self::SUCCESS_MESSAGE, $actualMessages, 'Wrong success message is displayed.' . "\nExpected: " . self::SUCCESS_MESSAGE . "\nActual: " . implode(',', $actualMessages));
}
示例8: processAssert
/**
* Assert that after adding products by sku, wrong requested quantity error message appears.
*
* @param CheckoutCart $checkoutCart
* @param array $requiredAttentionProducts
* @return void
*/
public function processAssert(CheckoutCart $checkoutCart, array $requiredAttentionProducts)
{
foreach ($requiredAttentionProducts as $product) {
$currentMessage = $checkoutCart->getAdvancedCheckoutCart()->getFailedItemErrorMessage($product);
\PHPUnit_Framework_Assert::assertContains(self::ERROR_QUANTITY_MESSAGE, $currentMessage);
\PHPUnit_Framework_Assert::assertContains(sprintf($this->allowedQtyMessage, $product->getStockData()[$this->saleQtyType]), $currentMessage);
}
}
示例9: processAssert
/**
* Assert that requested quantity is not available error message is displayed after adding products to cart by sku.
*
* @param CheckoutCart $checkoutCart
* @param array $requiredAttentionProducts
* @return void
*/
public function processAssert(CheckoutCart $checkoutCart, $requiredAttentionProducts)
{
foreach ($requiredAttentionProducts as $product) {
$currentMessage = $checkoutCart->getAdvancedCheckoutCart()->getFailedItemErrorMessage($product);
\PHPUnit_Framework_Assert::assertContains(self::ERROR_QUANTITY_MESSAGE, $currentMessage);
\PHPUnit_Framework_Assert::assertContains(sprintf(self::LEFT_IN_STOCK_ERROR_MESSAGE, $product->getStockData()['qty']), $currentMessage);
}
}
示例10: processAssert
/**
* Assert that part of license agreement text is present on Terms & Agreement page.
*
* @param Install $installPage
* @return void
*/
public function processAssert(Install $installPage)
{
try {
\PHPUnit_Framework_Assert::assertContains(self::LICENSE_AGREEMENT_TEXT, $installPage->getLicenseBlock()->getLicense(), 'License agreement text is absent.');
} catch (\Exception $e) {
\PHPUnit_Framework_Assert::assertContains(self::DEFAULT_LICENSE_AGREEMENT_TEXT, $installPage->getLicenseBlock()->getLicense(), 'License agreement text is absent.');
}
}
示例11: iOpenDialog
/**
* @Given /^I open "([^"]*)" dialog$/
*/
public function iOpenDialog($dialog)
{
$client = $this->getInstance();
$route = 'oro_' . str_replace(' ', '_', strtolower($dialog));
$client->request('GET', $client->generate($route));
\Oro\Bundle\TestFrameworkBundle\Test\ToolsAPI::assertJsonResponse($client->getResponse(), 200, '');
PHPUnit_Framework_Assert::assertContains('Create User - Users - System', $client->getCrawler()->html());
}
示例12: assertContains
function assertContains($expected, $collection)
{
foreach ($collection as $actual) {
if ($expected == $actual) {
return;
}
}
PHPUnit_Framework_Assert::assertContains($expected, $collection);
}
示例13: processAssert
/**
* Assert that readiness check items are passed.
*
* @param SetupWizard $setupWizard
* @return void
*/
public function processAssert(SetupWizard $setupWizard)
{
\PHPUnit_Framework_Assert::assertContains(self::UPDATER_APPLICATION_MESSAGE, $setupWizard->getReadiness()->getUpdaterApplicationCheck(), 'Updater application check is incorrect.');
\PHPUnit_Framework_Assert::assertContains(self::CRON_SCRIPT_MESSAGE, $setupWizard->getReadiness()->getCronScriptCheck(), 'Cron scripts are incorrect.');
\PHPUnit_Framework_Assert::assertContains(self::DEPENDENCY_CHECK_MESSAGE, $setupWizard->getReadiness()->getDependencyCheck(), 'Dependency check is incorrect.');
\PHPUnit_Framework_Assert::assertContains(self::PHP_VERSION_MESSAGE, $setupWizard->getReadiness()->getPhpVersionCheck(), 'PHP version is incorrect.');
\PHPUnit_Framework_Assert::assertContains(self::PHP_SETTING_REGEXP, $setupWizard->getReadiness()->getSettingsCheck(), 'PHP settings check failed.');
\PHPUnit_Framework_Assert::assertRegExp(self::PHP_EXTENSIONS_REGEXP, $setupWizard->getReadiness()->getPhpExtensionsCheck(), 'PHP extensions missed.');
}
示例14: theFieldShouldHaveAnErrorContaining
/**
* @Then the field :name should have an error containing :message
*/
public function theFieldShouldHaveAnErrorContaining($name, $message)
{
$field = $this->assertSession()->fieldExists($name);
$parent = $field->getParent();
if (false === stripos($parent->getAttribute('class'), $this->fieldContainerClass)) {
$parent = $parent->getParent();
}
Assert::assertContains($message, $parent->getText());
}
示例15: processAssert
/**
* Assert that comment about captured amount exist in Comments History section on order page in Admin.
*
* @param SalesOrderView $salesOrderView
* @param OrderIndex $salesOrder
* @param string $orderId
* @param array $capturedPrices
* @return void
*/
public function processAssert(SalesOrderView $salesOrderView, OrderIndex $salesOrder, $orderId, array $capturedPrices)
{
$salesOrder->open();
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
$actualCapturedAmount = $salesOrderView->getOrderHistoryBlock()->getCapturedAmount();
foreach ($capturedPrices as $key => $capturedPrice) {
\PHPUnit_Framework_Assert::assertContains(self::CAPTURED_AMOUNT . $capturedPrice, $actualCapturedAmount[$key], 'Incorrect captured amount value for the order #' . $orderId);
}
}