Merge branch 'MDL-72496-39_assert_tag' of https://github.com/call-learning/moodle into MOODLE_39_STABLE
This commit is contained in:
@@ -55,7 +55,7 @@ abstract class base_testcase extends PHPUnit\Framework\TestCase {
|
||||
public static function assertTag($matcher, $actual, $message = '', $ishtml = true) {
|
||||
$dom = PHPUnit\Util\XML::load($actual, $ishtml);
|
||||
$tags = self::findNodes($dom, $matcher, $ishtml);
|
||||
$matched = count($tags) > 0 && $tags[0] instanceof DOMNode;
|
||||
$matched = (is_array($tags) && count($tags) > 0) && $tags[0] instanceof DOMNode;
|
||||
self::assertTrue($matched, $message);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,16 @@ STRING;
|
||||
$this->testassertexecuted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assert Tag
|
||||
*/
|
||||
public function test_assert_tag() {
|
||||
// This should succeed.
|
||||
self::assertTag(['id' => 'testid'], "<div><span id='testid'></span></div>");
|
||||
$this->expectException(\PHPUnit\Framework\ExpectationFailedException::class);
|
||||
self::assertTag(['id' => 'testid'], "<div><div>");
|
||||
}
|
||||
|
||||
// Uncomment following tests to see logging of unexpected changes in global state and database.
|
||||
/*
|
||||
public function test_db_modification() {
|
||||
|
||||
Reference in New Issue
Block a user