Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Sep 5, 2024
1 parent 71d2a82 commit 2eb92d2
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace WP_Rocket\Tests\Integration\inc\Engine\Optimization\LazyRenderContent\Frontend\Filter;

use WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Processor\Dom;
use WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\Processor\HelperTrait;
use WP_Rocket\Tests\Integration\TestCase;
use ReflectionClass;

/**
* Test class covering \WP_Rocket\Engine\Optimization\LazyRenderContent\Frontend\ProcessorHelperTrait::get_processed_tags()
*
* @group PerformanceHints
*/
class Test_lrcProcessedTagsFilter extends TestCase
{
public function testShouldReturnAsExpected() {
add_filter( 'rocket_lazy_render_content_processed_tags', function( $tags ) {
$tags[]= 'h2';
$tags[]= 'h1';
$tags[]= 'li';

return $tags;
});

$dom = new Dom();
$instance = new ReflectionClass( $dom );
$method = $instance->getMethod( 'get_processed_tags' );

$method->setAccessible(true);
$result = $method->invoke( $dom );

$expected = [ 'DIV', 'MAIN', 'FOOTER', 'SECTION', 'ARTICLE', 'HEADER', 'H2', 'H1', 'LI' ];

$this->assertSame( $expected, $result );
}
}

0 comments on commit 2eb92d2

Please sign in to comment.