当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Framework_Assert::assertContains方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:unexge,项目名称:symfony,代码行数:32,代码来源:ErrorAssert.php

示例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);
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:16,代码来源:AssertOrderCommentsHistory.php

示例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.');
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:17,代码来源:AssertCmsPageDisabledOnUnassignedStoreView.php

示例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)));
 }
开发者ID:weavora,项目名称:mink-extra-context,代码行数:11,代码来源:TableContext.php

示例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());
 }
开发者ID:kieljohn,项目名称:TenantBundle,代码行数:10,代码来源:TenantBundleContext.php

示例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());
 }
开发者ID:ramunasd,项目名称:platform,代码行数:11,代码来源:FeatureContext.php

示例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));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:AssertCatalogPriceRuleSuccessSaveMessage.php

示例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);
     }
 }
开发者ID:MikeTayC,项目名称:magento.dev,代码行数:15,代码来源:AbstractAssertRequestedQtyFailMessage.php

示例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);
     }
 }
开发者ID:QiuLihua83,项目名称:magento-ee,代码行数:15,代码来源:AssertQtyIsNotEnoughFailMessage.php

示例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.');
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:AssertAgreementTextPresent.php

示例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());
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:11,代码来源:FeatureContext.php

示例12: assertContains

function assertContains($expected, $collection)
{
    foreach ($collection as $actual) {
        if ($expected == $actual) {
            return;
        }
    }
    PHPUnit_Framework_Assert::assertContains($expected, $collection);
}
开发者ID:electromute,项目名称:gnip-php,代码行数:9,代码来源:test_helper.php

示例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.');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:AssertSuccessfulReadinessCheck.php

示例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());
 }
开发者ID:treehouselabs,项目名称:behat-common,代码行数:12,代码来源:FormContext.php

示例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);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:18,代码来源:AssertCaptureInCommentsHistory.php


注:本文中的PHPUnit_Framework_Assert::assertContains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。