Changeset 52266 for trunk/tests/phpunit/tests/block-template-utils.php
- Timestamp:
- 11/29/2021 08:45:31 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/block-template-utils.php
r52265 r52266 1 1 <?php 2 2 /** 3 * Block_Template_Utils_Testclass3 * Tests_Block_Template_Utils class 4 4 * 5 * @package 5 * @package WordPress 6 6 */ 7 7 … … 85 85 86 86 $this->assertNotWPError( $template ); 87 $this->assert Equals( get_stylesheet() . '//my_template', $template->id );88 $this->assert Equals( get_stylesheet(), $template->theme );89 $this->assert Equals( 'my_template', $template->slug );90 $this->assert Equals( 'publish', $template->status );91 $this->assert Equals( 'custom', $template->source );92 $this->assert Equals( 'My Template', $template->title );93 $this->assert Equals( 'Description of my template', $template->description );94 $this->assert Equals( 'wp_template', $template->type );87 $this->assertSame( get_stylesheet() . '//my_template', $template->id ); 88 $this->assertSame( get_stylesheet(), $template->theme ); 89 $this->assertSame( 'my_template', $template->slug ); 90 $this->assertSame( 'publish', $template->status ); 91 $this->assertSame( 'custom', $template->source ); 92 $this->assertSame( 'My Template', $template->title ); 93 $this->assertSame( 'Description of my template', $template->description ); 94 $this->assertSame( 'wp_template', $template->type ); 95 95 96 96 // Test template parts. … … 100 100 ); 101 101 $this->assertNotWPError( $template_part ); 102 $this->assert Equals( get_stylesheet() . '//my_template_part', $template_part->id );103 $this->assert Equals( get_stylesheet(), $template_part->theme );104 $this->assert Equals( 'my_template_part', $template_part->slug );105 $this->assert Equals( 'publish', $template_part->status );106 $this->assert Equals( 'custom', $template_part->source );107 $this->assert Equals( 'My Template Part', $template_part->title );108 $this->assert Equals( 'Description of my template part', $template_part->description );109 $this->assert Equals( 'wp_template_part', $template_part->type );110 $this->assert Equals( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area );102 $this->assertSame( get_stylesheet() . '//my_template_part', $template_part->id ); 103 $this->assertSame( get_stylesheet(), $template_part->theme ); 104 $this->assertSame( 'my_template_part', $template_part->slug ); 105 $this->assertSame( 'publish', $template_part->status ); 106 $this->assertSame( 'custom', $template_part->source ); 107 $this->assertSame( 'My Template Part', $template_part->title ); 108 $this->assertSame( 'Description of my template part', $template_part->description ); 109 $this->assertSame( 'wp_template_part', $template_part->type ); 110 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area ); 111 111 } 112 112 … … 120 120 ); 121 121 122 $this->assert Equals( get_stylesheet() . '//single', $template->id );123 $this->assert Equals( get_stylesheet(), $template->theme );124 $this->assert Equals( 'single', $template->slug );125 $this->assert Equals( 'publish', $template->status );126 $this->assert Equals( 'theme', $template->source );127 $this->assert Equals( 'Single Post', $template->title );128 $this->assert Equals( 'Template used to display a single blog post.', $template->description );129 $this->assert Equals( 'wp_template', $template->type );122 $this->assertSame( get_stylesheet() . '//single', $template->id ); 123 $this->assertSame( get_stylesheet(), $template->theme ); 124 $this->assertSame( 'single', $template->slug ); 125 $this->assertSame( 'publish', $template->status ); 126 $this->assertSame( 'theme', $template->source ); 127 $this->assertSame( 'Single Post', $template->title ); 128 $this->assertSame( 'Template used to display a single blog post.', $template->description ); 129 $this->assertSame( 'wp_template', $template->type ); 130 130 131 131 // Test template parts. … … 138 138 'wp_template_part' 139 139 ); 140 $this->assert Equals( get_stylesheet() . '//header', $template_part->id );141 $this->assert Equals( get_stylesheet(), $template_part->theme );142 $this->assert Equals( 'header', $template_part->slug );143 $this->assert Equals( 'publish', $template_part->status );144 $this->assert Equals( 'theme', $template_part->source );145 $this->assert Equals( 'header', $template_part->title );146 $this->assert Equals( '', $template_part->description );147 $this->assert Equals( 'wp_template_part', $template_part->type );148 $this->assert Equals( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area );140 $this->assertSame( get_stylesheet() . '//header', $template_part->id ); 141 $this->assertSame( get_stylesheet(), $template_part->theme ); 142 $this->assertSame( 'header', $template_part->slug ); 143 $this->assertSame( 'publish', $template_part->status ); 144 $this->assertSame( 'theme', $template_part->source ); 145 $this->assertSame( 'header', $template_part->title ); 146 $this->assertSame( '', $template_part->description ); 147 $this->assertSame( 'wp_template_part', $template_part->type ); 148 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area ); 149 149 } 150 150 … … 160 160 get_stylesheet() 161 161 ); 162 $this->assert Equals( $expected, $template_content );162 $this->assertSame( $expected, $template_content ); 163 163 164 164 $content_without_theme_attribute_nested = '<!-- wp:group --><!-- wp:template-part {"slug":"header","align":"full", "tagName":"header","className":"site-header"} /--><!-- /wp:group -->'; … … 171 171 get_stylesheet() 172 172 ); 173 $this->assert Equals( $expected, $template_content );173 $this->assertSame( $expected, $template_content ); 174 174 175 175 // Does not inject theme when there is an existing theme attribute. … … 179 179 $theme 180 180 ); 181 $this->assert Equals( $content_with_existing_theme_attribute, $template_content );181 $this->assertSame( $content_with_existing_theme_attribute, $template_content ); 182 182 183 183 // Does not inject theme when there is no template part. … … 187 187 $theme 188 188 ); 189 $this->assert Equals( $content_with_no_template_part, $template_content );189 $this->assertSame( $content_with_no_template_part, $template_content ); 190 190 } 191 191 … … 198 198 /* $id = get_stylesheet() . '//' . 'index'; 199 199 $template = get_block_template( $id, 'wp_template' ); 200 $this->assert Equals( $id, $template->id );201 $this->assert Equals( get_stylesheet(), $template->theme );202 $this->assert Equals( 'index', $template->slug );203 $this->assert Equals( 'publish', $template->status );204 $this->assert Equals( 'theme', $template->source );205 $this->assert Equals( 'wp_template', $template->type );200 $this->assertSame( $id, $template->id ); 201 $this->assertSame( get_stylesheet(), $template->theme ); 202 $this->assertSame( 'index', $template->slug ); 203 $this->assertSame( 'publish', $template->status ); 204 $this->assertSame( 'theme', $template->source ); 205 $this->assertSame( 'wp_template', $template->type ); 206 206 207 207 // Test template parts. 208 208 $id = get_stylesheet() . '//' . 'header'; 209 209 $template = get_block_template( $id, 'wp_template_part' ); 210 $this->assert Equals( $id, $template->id );211 $this->assert Equals( get_stylesheet(), $template->theme );212 $this->assert Equals( 'header', $template->slug );213 $this->assert Equals( 'publish', $template->status );214 $this->assert Equals( 'theme', $template->source );215 $this->assert Equals( 'wp_template_part', $template->type );216 $this->assert Equals( WP_TEMPLATE_PART_AREA_HEADER, $template->area );210 $this->assertSame( $id, $template->id ); 211 $this->assertSame( get_stylesheet(), $template->theme ); 212 $this->assertSame( 'header', $template->slug ); 213 $this->assertSame( 'publish', $template->status ); 214 $this->assertSame( 'theme', $template->source ); 215 $this->assertSame( 'wp_template_part', $template->type ); 216 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template->area ); 217 217 */ 218 218 } … … 224 224 $id = get_stylesheet() . '//' . 'my_template'; 225 225 $template = get_block_template( $id, 'wp_template' ); 226 $this->assert Equals( $id, $template->id );227 $this->assert Equals( get_stylesheet(), $template->theme );228 $this->assert Equals( 'my_template', $template->slug );229 $this->assert Equals( 'publish', $template->status );230 $this->assert Equals( 'custom', $template->source );231 $this->assert Equals( 'wp_template', $template->type );226 $this->assertSame( $id, $template->id ); 227 $this->assertSame( get_stylesheet(), $template->theme ); 228 $this->assertSame( 'my_template', $template->slug ); 229 $this->assertSame( 'publish', $template->status ); 230 $this->assertSame( 'custom', $template->source ); 231 $this->assertSame( 'wp_template', $template->type ); 232 232 233 233 // Test template parts. 234 234 $id = get_stylesheet() . '//' . 'my_template_part'; 235 235 $template = get_block_template( $id, 'wp_template_part' ); 236 $this->assert Equals( $id, $template->id );237 $this->assert Equals( get_stylesheet(), $template->theme );238 $this->assert Equals( 'my_template_part', $template->slug );239 $this->assert Equals( 'publish', $template->status );240 $this->assert Equals( 'custom', $template->source );241 $this->assert Equals( 'wp_template_part', $template->type );242 $this->assert Equals( WP_TEMPLATE_PART_AREA_HEADER, $template->area );236 $this->assertSame( $id, $template->id ); 237 $this->assertSame( get_stylesheet(), $template->theme ); 238 $this->assertSame( 'my_template_part', $template->slug ); 239 $this->assertSame( 'publish', $template->status ); 240 $this->assertSame( 'custom', $template->source ); 241 $this->assertSame( 'wp_template_part', $template->type ); 242 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template->area ); 243 243 } 244 244 … … 269 269 $templates = get_block_templates( array( 'slug__in' => array( 'my_template' ) ), 'wp_template' ); 270 270 $template_ids = get_template_ids( $templates ); 271 $this->assert Equals( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );271 $this->assertSame( array( get_stylesheet() . '//' . 'my_template' ), $template_ids ); 272 272 273 273 // Filter by CPT ID. 274 274 $templates = get_block_templates( array( 'wp_id' => self::$post->ID ), 'wp_template' ); 275 275 $template_ids = get_template_ids( $templates ); 276 $this->assert Equals( array( get_stylesheet() . '//' . 'my_template' ), $template_ids );276 $this->assertSame( array( get_stylesheet() . '//' . 'my_template' ), $template_ids ); 277 277 278 278 // Filter template part by area. … … 280 280 /*$templates = get_block_templates( array( 'area' => WP_TEMPLATE_PART_AREA_HEADER ), 'wp_template_part' ); 281 281 $template_ids = get_template_ids( $templates ); 282 $this->assert Equals(282 $this->assertSame( 283 283 array( 284 284 get_stylesheet() . '//' . 'my_template_part', … … 298 298 $actual = _flatten_blocks( $blocks ); 299 299 $expected = array( $blocks[0], $blocks[0]['innerBlocks'][0] ); 300 $this->assert Equals( $expected, $actual );300 $this->assertSame( $expected, $actual ); 301 301 302 302 $content_template_part_inside_group_inside_group = '<!-- wp:group --><!-- wp:group --><!-- wp:template-part {"slug":"header"} /--><!-- /wp:group --><!-- /wp:group -->'; … … 304 304 $actual = _flatten_blocks( $blocks ); 305 305 $expected = array( $blocks[0], $blocks[0]['innerBlocks'][0], $blocks[0]['innerBlocks'][0]['innerBlocks'][0] ); 306 $this->assert Equals( $expected, $actual );306 $this->assertSame( $expected, $actual ); 307 307 308 308 $content_without_inner_blocks = '<!-- wp:group /-->'; … … 310 310 $actual = _flatten_blocks( $blocks ); 311 311 $expected = array( $blocks[0] ); 312 $this->assert Equals( $expected, $actual );312 $this->assertSame( $expected, $actual ); 313 313 } 314 314 }
Note: See TracChangeset
for help on using the changeset viewer.