diff --git a/tests/phpunit/TestHelpers/GetDomHelperTrait.php b/tests/phpunit/TestHelpers/GetDomHelperTrait.php
deleted file mode 100644
index e85ea020..00000000
--- a/tests/phpunit/TestHelpers/GetDomHelperTrait.php
+++ /dev/null
@@ -1,31 +0,0 @@
-get_DOM( $html_string );
+ $dom = str_get_html( $html_string );
$content['html'] = $dom;
$post = $this->factory()->post->create_and_get();
@@ -143,7 +125,7 @@ public function test_screen_reader_text_classes( string $sibling_class, bool $pa
Some text maybe for screenreaders
;
EOT;
- $dom = $this->get_DOM( $markup );
+ $dom = str_get_html( $markup );
$siblings = $dom->find( '.parent > *' );
$this->assertEquals( $pass, edac_rule_aria_hidden_siblings_are_screen_reader_text_elements( $siblings ) );
}
@@ -156,7 +138,7 @@ public function test_parent_with_label_that_is_not_link_or_button_errors() {
$test_elements = array( 'div', 'span', 'section' );
foreach ( $test_elements as $element ) {
$markup = "<$element aria-label='label'>$element>";
- $dom = $this->get_DOM( $markup );
+ $dom = str_get_html( $markup );
$errors = $this->get_errors_from_rule_check( $dom );
$this->assertNotEmpty( $errors );
}
@@ -166,12 +148,12 @@ public function test_parent_with_label_that_is_not_link_or_button_errors() {
* Test that parents with likely visible text pass.
*/
public function test_parent_with_likely_visible_text_passes() {
- $link_dom = $this->get_DOM( $this->get_test_markup( 'link_with_visible_text' ) );
+ $link_dom = str_get_html( $this->get_test_markup( 'link_with_visible_text' ) );
$link_element = $link_dom->find( '[aria-hidden="true"]' );
$link_parent = $link_element[0]->parent();
$this->assertNotEmpty( edac_rule_aria_hidden_strip_markup_and_return_text( $link_parent ) );
- $button_dom = $this->get_DOM( $this->get_test_markup( 'button_with_visible_text' ) );
+ $button_dom = str_get_html( $this->get_test_markup( 'button_with_visible_text' ) );
$button_element = $button_dom->find( '[aria-hidden="true"]' );
$button_parent = $button_element[0]->parent();
$this->assertNotEmpty( edac_rule_aria_hidden_strip_markup_and_return_text( $button_parent ) );
diff --git a/tests/phpunit/includes/rules/ImgAltRedundantTest.php b/tests/phpunit/includes/rules/ImgAltRedundantTest.php
index 109f4ac5..0cde12f2 100644
--- a/tests/phpunit/includes/rules/ImgAltRedundantTest.php
+++ b/tests/phpunit/includes/rules/ImgAltRedundantTest.php
@@ -11,14 +11,13 @@
* @group rules
*/
class ImgAltRedundantTest extends WP_UnitTestCase {
- use GetDomHelperTrait;
/**
* Test the rule catches redundant alt attributes on images.
*/
public function test_does_not_flag_duplicate_alt_when_alt_is_not_present() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$errors = edac_rule_img_alt_redundant( array( 'html' => $dom ), null );
$this->assertEmpty( $errors );
}
@@ -30,7 +29,7 @@ public function test_does_not_flag_duplicate_alt_when_alt_is_not_present() {
*/
public function test_idoes_not_flag_duplicate_alt_when_alt_is_empty_string() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$errors = edac_rule_img_alt_redundant( array( 'html' => $dom ), null );
$this->assertEmpty( $errors );
}
@@ -42,7 +41,7 @@ public function test_idoes_not_flag_duplicate_alt_when_alt_is_empty_string() {
*/
public function test_does_not_flag_duplicate_alt_when_alt_and_title_are_empty_strings() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$errors = edac_rule_img_alt_redundant( array( 'html' => $dom ), null );
$this->assertEmpty( $errors );
}
@@ -52,7 +51,7 @@ public function test_does_not_flag_duplicate_alt_when_alt_and_title_are_empty_st
*/
public function test_flags_images_where_alt_and_title_are_the_same() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$errors = edac_rule_img_alt_redundant( array( 'html' => $dom ), null );
$this->assertNotEmpty( $errors );
}
@@ -62,7 +61,7 @@ public function test_flags_images_where_alt_and_title_are_the_same() {
*/
public function test_img_alt_redundant_rule_does_not_flag_duplicate_alt_when_alt_and_title_are_different() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$errors = edac_rule_img_alt_redundant( array( 'html' => $dom ), null );
$this->assertEmpty( $errors );
}
diff --git a/tests/phpunit/includes/rules/ImgAnimatedGifTest.php b/tests/phpunit/includes/rules/ImgAnimatedGifTest.php
index a10cf7e5..0ec33244 100644
--- a/tests/phpunit/includes/rules/ImgAnimatedGifTest.php
+++ b/tests/phpunit/includes/rules/ImgAnimatedGifTest.php
@@ -50,7 +50,7 @@ public function testAnimatedWebpDetectionWithStaticWebp() {
*/
public function testRuleWithAnimatedGifInContent() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$content = array( 'html' => $dom );
$post = new stdClass();
$errors = edac_rule_img_animated_gif( $content, $post );
@@ -62,7 +62,7 @@ public function testRuleWithAnimatedGifInContent() {
*/
public function testRuleWithStaticGifInContent() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$content = array( 'html' => $dom );
$post = new stdClass();
$errors = edac_rule_img_animated_gif( $content, $post );
@@ -74,7 +74,7 @@ public function testRuleWithStaticGifInContent() {
*/
public function testRuleWithAnimatedWebpInContent() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$content = array( 'html' => $dom );
$post = new stdClass();
$errors = edac_rule_img_animated_gif( $content, $post );
@@ -87,28 +87,10 @@ public function testRuleWithAnimatedWebpInContent() {
public function testRuleWithStaticWebpInContent() {
$html = '';
- $dom = $this->get_DOM( $html );
+ $dom = str_get_html( $html );
$content = array( 'html' => $dom );
$post = new stdClass();
$errors = edac_rule_img_animated_gif( $content, $post );
$this->assertEmpty( $errors );
}
-
- /**
- * Wrapper to generate dom objects that match the shape of the object in the plugin.
- *
- * @param string $html_string HTML string.
- * @return EDAC_Dom
- */
- private function get_DOM( string $html_string = '' ) {
- return new EDAC_Dom(
- $html_string,
- true,
- true,
- DEFAULT_TARGET_CHARSET,
- true,
- DEFAULT_BR_TEXT,
- DEFAULT_SPAN_TEXT
- );
- }
}