Changeset 58422 for trunk/tests/phpunit/tests/theme/wpThemeJson.php
- Timestamp:
- 06/17/2024 09:42:57 AM (2 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/theme/wpThemeJson.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r58378 r58422 5501 5501 $this->assertEquals( $expected, $actual ); 5502 5502 } 5503 5504 /** 5505 * Block style variations styles aren't generated by default. This test covers 5506 * the `get_block_nodes` does not include variations by default, preventing 5507 * the inclusion of their styles. 5508 * 5509 * @ticket 61443 5510 */ 5511 public function test_opt_out_of_block_style_variations_by_default() { 5512 $theme_json = new ReflectionClass( 'WP_Theme_JSON' ); 5513 5514 $func = $theme_json->getMethod( 'get_block_nodes' ); 5515 $func->setAccessible( true ); 5516 5517 $theme_json = array( 5518 'version' => WP_Theme_JSON::LATEST_SCHEMA, 5519 'styles' => array( 5520 'blocks' => array( 5521 'core/button' => array( 5522 'variations' => array( 5523 'outline' => array( 5524 'color' => array( 5525 'background' => 'red', 5526 ), 5527 ), 5528 ), 5529 ), 5530 ), 5531 ), 5532 ); 5533 $selectors = array(); 5534 5535 $block_nodes = $func->invoke( null, $theme_json, $selectors ); 5536 $button_variations = $block_nodes[0]['variations'] ?? array(); 5537 5538 $this->assertEquals( array(), $button_variations ); 5539 } 5540 5541 /** 5542 * Block style variations styles aren't generated by default. This test ensures 5543 * variations are included by `get_block_nodes` when requested. 5544 * 5545 * @ticket 61443 5546 */ 5547 public function test_opt_in_to_block_style_variations() { 5548 $theme_json = new ReflectionClass( 'WP_Theme_JSON' ); 5549 5550 $func = $theme_json->getMethod( 'get_block_nodes' ); 5551 $func->setAccessible( true ); 5552 5553 $theme_json = array( 5554 'version' => WP_Theme_JSON::LATEST_SCHEMA, 5555 'styles' => array( 5556 'blocks' => array( 5557 'core/button' => array( 5558 'variations' => array( 5559 'outline' => array( 5560 'color' => array( 5561 'background' => 'red', 5562 ), 5563 ), 5564 ), 5565 ), 5566 ), 5567 ), 5568 ); 5569 $selectors = array(); 5570 $options = array( 'include_block_style_variations' => true ); 5571 5572 $block_nodes = $func->invoke( null, $theme_json, $selectors, $options ); 5573 $button_variations = $block_nodes[0]['variations'] ?? array(); 5574 5575 $expected = array( 5576 array( 5577 'path' => array( 'styles', 'blocks', 'core/button', 'variations', 'outline' ), 5578 'selector' => '.wp-block-button.is-style-outline .wp-block-button__link', 5579 ), 5580 ); 5581 5582 $this->assertEquals( $expected, $button_variations ); 5583 } 5503 5584 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)