Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Apr 26, 2022
1 parent b0e6eb9 commit 024eaf0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/php/test-amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ public function test_amp_register_default_scripts_and_styles_with_bento() {
'amp-animation' => 'v0/amp-animation-0.1.js',
'amp-apester-media' => 'v0/amp-apester-media-0.1.js',
'amp-app-banner' => 'v0/amp-app-banner-0.1.js',
'amp-audio' => 'v0/amp-audio-0.1.js',
'amp-audio' => 'v0/amp-audio-1.0.js',
'amp-auto-ads' => 'v0/amp-auto-ads-0.1.js',
'amp-autocomplete' => 'v0/amp-autocomplete-0.1.js',
'amp-base-carousel' => 'v0/amp-base-carousel-1.0.js',
Expand Down
14 changes: 9 additions & 5 deletions tests/php/validation/test-class-amp-validation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ public function get_block_data() {
'latest_posts' => [
'<!-- wp:latest-posts {"postsToShow":1} /-->',
sprintf(
'<!--amp-source-stack {"block_name":"core\/latest-posts","post_id":{{post_id}},"block_content_index":0,"block_attrs":{"postsToShow":1},"type":"%1$s","name":"%2$s","file":%4$s,"line":%5$s,"function":"%3$s"}--><ul class="%6$s"><li><a href="{{url}}">{{title}}</a></li></ul><!--/amp-source-stack {"block_name":"core\/latest-posts","post_id":{{post_id}},"block_attrs":{"postsToShow":1},"type":"%1$s","name":"%2$s","file":%4$s,"line":%5$s,"function":"%3$s"}-->',
'<!--amp-source-stack {"block_name":"core\/latest-posts","post_id":{{post_id}},"block_content_index":0,"block_attrs":{"postsToShow":1},"type":"%1$s","name":"%2$s","file":%4$s,"line":%5$s,"function":"%3$s"}--><ul class="wp-block-latest-posts wp-block-latest-posts__list"><li><a href="{{url}}">{{title}}</a></li></ul><!--/amp-source-stack {"block_name":"core\/latest-posts","post_id":{{post_id}},"block_attrs":{"postsToShow":1},"type":"%1$s","name":"%2$s","file":%4$s,"line":%5$s,"function":"%3$s"}-->',
$is_gutenberg ? 'plugin' : 'core',
$is_gutenberg ? 'gutenberg' : 'wp-includes',
$latest_posts_block->render_callback instanceof Closure ? '{closure}' : $latest_posts_block->render_callback,
Expand All @@ -1347,10 +1347,7 @@ public function get_block_data() {
? preg_replace( ':.*gutenberg/:', '', $reflection_function->getFileName() )
: preg_replace( ':.*wp-includes/:', '', $reflection_function->getFileName() )
),
$reflection_function->getStartLine(),
( defined( 'GUTENBERG_DEVELOPMENT_MODE' ) || defined( 'GUTENBERG_VERSION' ) && GUTENBERG_VERSION && version_compare( GUTENBERG_VERSION, '8.8.0', '>=' ) )
? 'wp-block-latest-posts__list wp-block-latest-posts'
: 'wp-block-latest-posts wp-block-latest-posts__list'
$reflection_function->getStartLine()
),
[
'element' => 'ul',
Expand Down Expand Up @@ -1416,6 +1413,13 @@ public function test_add_block_source_comments( $content, $expected, $query ) {
// Remove class added in <https://github.com/WordPress/gutenberg/pull/38740> to normalize with expected data.
$rendered_block = str_replace( ' class="wp-block-latest-posts__post-title"', '', $rendered_block );

// Normalize class ordering.
$rendered_block = str_replace(
'wp-block-latest-posts__list wp-block-latest-posts',
'wp-block-latest-posts wp-block-latest-posts__list',
$rendered_block
);

$this->assertEquals(
preg_replace( '/(?<=>)\s+(?=<)/', '', str_replace( '%d', $post->ID, $expected ) ),
preg_replace( '/(?<=>)\s+(?=<)/', '', $rendered_block )
Expand Down

0 comments on commit 024eaf0

Please sign in to comment.