assertHtml($pattern, $input);
}
/**
* Test that assertHtml runs quickly.
*
* @return void
*/
public function testAssertHtmlRuntimeComplexity()
{
$pattern = [
'div' => [
'attr1' => 'val1',
'attr2' => 'val2',
'attr3' => 'val3',
'attr4' => 'val4',
'attr5' => 'val5',
'attr6' => 'val6',
'attr7' => 'val7',
'attr8' => 'val8',
],
'My div',
'/div',
];
$input = '' .
'My div' .
'';
$this->assertHtml($pattern, $input);
}
/**
* test that assertHtml knows how to handle correct quoting.
*
* @return void
*/
public function testAssertHtmlQuotes()
{
$input = 'My link';
$pattern = [
'a' => ['href' => '/test.html', 'class' => 'active'],
'My link',
'/a',
];
$this->assertHtml($pattern, $input);
$input = "My link";
$pattern = [
'a' => ['href' => '/test.html', 'class' => 'active'],
'My link',
'/a',
];
$this->assertHtml($pattern, $input);
$input = "My link";
$pattern = [
'a' => ['href' => 'preg:/.*\.html/', 'class' => 'active'],
'My link',
'/a',
];
$this->assertHtml($pattern, $input);
}
/**
* testNumericValuesInExpectationForAssertHtml
*
* @return void
*/
public function testNumericValuesInExpectationForAssertHtml()
{
$value = 220985;
$input = '' . $value . '
';
$pattern = [
'assertHtml($pattern, $input);
$input = '
' . $value . '
' . $value . '
';
$pattern = [
'assertHtml($pattern, $input);
$input = '
' . $value . '
' . $value . '
';
$pattern = [
' ['id' => $value],
'assertHtml($pattern, $input);
}
/**
* test assertions fail when attributes are wrong.
*
* @return void
*/
public function testBadAssertHtmlInvalidAttribute()
{
$input = 'My link';
$pattern = [
'a' => ['hRef' => '/test.html', 'clAss' => 'active'],
'My link2',
'/a',
];
try {
$this->assertHtml($pattern, $input);
$this->fail('Assertion should fail');
} catch (ExpectationFailedException $e) {
$this->assertContains(
'Attribute did not match. Was expecting Attribute "clAss" == "active"',
$e->getMessage()
);
}
}
/**
* test assertion failure on incomplete HTML
*
* @return void
*/
public function testBadAssertHtmlMissingTags()
{
$input = 'My link';
$pattern = [
' ['href' => '/test.html', 'class' => 'active'],
'My link',
'/a',
];
try {
$this->assertHtml($pattern, $input);
} catch (ExpectationFailedException $e) {
$this->assertContains(
'Item #1 / regex #0 failed: Open getMessage()
);
}
}
}