lithium\test\Unit::assertStringMatchesFormat()
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
booleantrue
if the assertion succeeded, false
otherwise.
Links
Source
public function assertStringMatchesFormat($expected, $actual, $message = '{:message}') {
$result = sscanf($actual, $expected);
return $this->assert($result[0] == $actual, $message, compact('expected', 'result'));
}