lithium\test\Unit::assertStringMatchesFormat()

public method

Assert that given value matches the sprintf format.

$this->assertStringMatchesFormat('%d', '10'); // succeeds
$this->assertStringMatchesFormat('%d', '10.555'); // fails

Parameters

  • string $expected

    Expected format using sscanf's format.

  • string $actual
  • string|boolean $message

Returns

boolean

true if the assertion succeeded, false otherwise.

Source

	public function assertStringMatchesFormat($expected, $actual, $message = '{:message}') {
		$result = sscanf($actual, $expected);
		return $this->assert($result[0] == $actual, $message, compact('expected', 'result'));
	}