lithium\test\Unit::assertNotContains()

public method

Assert that $haystack does not contain $needle as a value.

$this->assertNotContains(4, [1,2,3]); // succeeds
$this->assertNotContains('foo', ['foo', 'bar', 'baz']); // fails

Parameters

  • string $needle

    The needle you are looking for.

  • miexed $haystack

    Array or iterable object or a string.

  • string|boolean $message

Returns

boolean

true if the assertion succeeded, false otherwise.

Source

	public function assertNotContains($needle, $haystack, $message = '{:message}') {
		if (is_string($haystack)) {
			return $this->assert(strpos($haystack, $needle) === false, $message, [
				'expected' => $needle,
				'result' => $haystack
			]);
		}
		foreach ($haystack as $key => $value) {
			if ($value === $needle) {
				return $this->assert(false, $message, [
					'expected' => $needle,
					'result' => $haystack
				]);
			}
		}
		return $this->assert(true, $message, [
			'expected' => $needle,
			'result' => $haystack
		]);
	}