PHPUnit_Framework_Assert::assertContains PHP Method

assertContains() public static method

Asserts that a haystack contains a needle.
public static assertContains ( mixed $needle, mixed $haystack, string $message = '', boolean $ignoreCase = false, boolean $checkForObjectIdentity = true, boolean $checkForNonObjectIdentity = false )
$needle mixed
$haystack mixed
$message string
$ignoreCase boolean
$checkForObjectIdentity boolean
$checkForNonObjectIdentity boolean
    public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false)
    {
        if (is_array($haystack) || is_object($haystack) && $haystack instanceof Traversable) {
            $constraint = new PHPUnit_Framework_Constraint_TraversableContains($needle, $checkForObjectIdentity, $checkForNonObjectIdentity);
        } elseif (is_string($haystack)) {
            if (!is_string($needle)) {
                throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
            }
            $constraint = new PHPUnit_Framework_Constraint_StringContains($needle, $ignoreCase);
        } else {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'array, traversable or string');
        }
        static::assertThat($haystack, $constraint, $message);
    }

Usage Example

 /**
  * 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);
 }
All Usage Examples Of PHPUnit_Framework_Assert::assertContains
PHPUnit_Framework_Assert