Tester\Assert::notContains PHP Method

notContains() public static method

Checks assertion. Values must not contains expected needle.
public static notContains ( $needle, $actual, $description = NULL ) : void
return void
    public static function notContains($needle, $actual, $description = NULL)
    {
        self::$counter++;
        if (is_array($actual)) {
            if (in_array($needle, $actual, TRUE)) {
                self::fail(self::describe('%1 should not contain %2', $description), $actual, $needle);
            }
        } elseif (is_string($actual)) {
            if ($needle === '' || strpos($actual, $needle) !== FALSE) {
                self::fail(self::describe('%1 should not contain %2', $description), $actual, $needle);
            }
        } else {
            self::fail(self::describe('%1 should be string or array', $description), $actual);
        }
    }

Usage Example

Ejemplo n.º 1
0
 public static function hasNot($expected)
 {
     return static::match(function ($arg) use($expected) {
         Assert::notContains($expected, $arg);
     });
 }