Changeset 53129 for trunk/tests/phpunit/tests/theme/wpThemeJson.php
- Timestamp:
- 04/11/2022 10:36:02 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r52434 r53129 424 424 ); 425 425 426 $expected = 'body { margin: 0; }body{--wp--style--block-gap: 1em;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin- top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }';427 $this->assert Same( $expected, $theme_json->get_stylesheet() );428 $this->assert Same( $expected, $theme_json->get_stylesheet( array( 'styles' ) ) );426 $expected = 'body { margin: 0; }body{--wp--style--block-gap: 1em;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }.wp-site-blocks > * + * { margin-block-start: var( --wp--style--block-gap ); }'; 427 $this->assertEquals( $expected, $theme_json->get_stylesheet() ); 428 $this->assertEquals( $expected, $theme_json->get_stylesheet( array( 'styles' ) ) ); 429 429 } 430 430 … … 554 554 555 555 $variables = 'body{--wp--preset--color--grey: grey;--wp--preset--font-family--small: 14px;--wp--preset--font-family--big: 41px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}'; 556 $styles = 'body { margin: 0; }body{color: var(--wp--preset--color--grey);}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin- top: 0; margin-bottom: 0; }.wp-site-blocks > * + * { margin-top: var( --wp--style--block-gap ); }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}';556 $styles = 'body { margin: 0; }body{color: var(--wp--preset--color--grey);}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }.wp-site-blocks > * + * { margin-block-start: var( --wp--style--block-gap ); }a{background-color: #333;color: #111;}.wp-block-group{border-radius: 10px;padding: 24px;}.wp-block-group a{color: #111;}h1,h2,h3,h4,h5,h6{color: #123456;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{background-color: #333;color: #111;font-size: 60px;}.wp-block-post-date{color: #123456;}.wp-block-post-date a{background-color: #777;color: #555;}.wp-block-image{border-top-left-radius: 10px;border-bottom-right-radius: 1em;margin-bottom: 30px;}'; 557 557 $presets = '.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-small-font-family{font-family: var(--wp--preset--font-family--small) !important;}.has-big-font-family{font-family: var(--wp--preset--font-family--big) !important;}'; 558 558 $all = $variables . $styles . $presets; 559 $this->assert Same( $all, $theme_json->get_stylesheet() );560 $this->assert Same( $styles, $theme_json->get_stylesheet( array( 'styles' ) ) );561 $this->assert Same( $presets, $theme_json->get_stylesheet( array( 'presets' ) ) );562 $this->assert Same( $variables, $theme_json->get_stylesheet( array( 'variables' ) ) );559 $this->assertEquals( $all, $theme_json->get_stylesheet() ); 560 $this->assertEquals( $styles, $theme_json->get_stylesheet( array( 'styles' ) ) ); 561 $this->assertEquals( $presets, $theme_json->get_stylesheet( array( 'presets' ) ) ); 562 $this->assertEquals( $variables, $theme_json->get_stylesheet( array( 'variables' ) ) ); 563 563 } 564 564 … … 2385 2385 } 2386 2386 2387 /** 2388 * @ticket 55505 2389 */ 2390 function test_export_data() { 2391 $theme = new WP_Theme_JSON( 2392 array( 2393 'version' => 2, 2394 'settings' => array( 2395 'color' => array( 2396 'palette' => array( 2397 array( 2398 'slug' => 'white', 2399 'color' => 'white', 2400 'label' => 'White', 2401 ), 2402 array( 2403 'slug' => 'black', 2404 'color' => 'black', 2405 'label' => 'Black', 2406 ), 2407 ), 2408 ), 2409 ), 2410 ) 2411 ); 2412 $user = new WP_Theme_JSON( 2413 array( 2414 'version' => 2, 2415 'settings' => array( 2416 'color' => array( 2417 'palette' => array( 2418 array( 2419 'slug' => 'white', 2420 'color' => '#fff', 2421 'label' => 'User White', 2422 ), 2423 array( 2424 'slug' => 'hotpink', 2425 'color' => 'hotpink', 2426 'label' => 'hotpink', 2427 ), 2428 ), 2429 ), 2430 ), 2431 ), 2432 'custom' 2433 ); 2434 2435 $theme->merge( $user ); 2436 $actual = $theme->get_data(); 2437 $expected = array( 2438 'version' => 2, 2439 'settings' => array( 2440 'color' => array( 2441 'palette' => array( 2442 array( 2443 'slug' => 'white', 2444 'color' => '#fff', 2445 'label' => 'User White', 2446 ), 2447 array( 2448 'slug' => 'black', 2449 'color' => 'black', 2450 'label' => 'Black', 2451 ), 2452 array( 2453 'slug' => 'hotpink', 2454 'color' => 'hotpink', 2455 'label' => 'hotpink', 2456 ), 2457 ), 2458 ), 2459 ), 2460 ); 2461 2462 $this->assertEqualSetsWithIndex( $expected, $actual ); 2463 } 2464 2465 /** 2466 * @ticket 55505 2467 */ 2468 function test_export_data_deals_with_empty_user_data() { 2469 $theme = new WP_Theme_JSON( 2470 array( 2471 'version' => 2, 2472 'settings' => array( 2473 'color' => array( 2474 'palette' => array( 2475 array( 2476 'slug' => 'white', 2477 'color' => 'white', 2478 'label' => 'White', 2479 ), 2480 array( 2481 'slug' => 'black', 2482 'color' => 'black', 2483 'label' => 'Black', 2484 ), 2485 ), 2486 ), 2487 ), 2488 ) 2489 ); 2490 2491 $actual = $theme->get_data(); 2492 $expected = array( 2493 'version' => 2, 2494 'settings' => array( 2495 'color' => array( 2496 'palette' => array( 2497 array( 2498 'slug' => 'white', 2499 'color' => 'white', 2500 'label' => 'White', 2501 ), 2502 array( 2503 'slug' => 'black', 2504 'color' => 'black', 2505 'label' => 'Black', 2506 ), 2507 ), 2508 ), 2509 ), 2510 ); 2511 2512 $this->assertEqualSetsWithIndex( $expected, $actual ); 2513 } 2514 2515 /** 2516 * @ticket 55505 2517 */ 2518 function test_export_data_deals_with_empty_theme_data() { 2519 $user = new WP_Theme_JSON( 2520 array( 2521 'version' => 2, 2522 'settings' => array( 2523 'color' => array( 2524 'palette' => array( 2525 array( 2526 'slug' => 'white', 2527 'color' => '#fff', 2528 'label' => 'User White', 2529 ), 2530 array( 2531 'slug' => 'hotpink', 2532 'color' => 'hotpink', 2533 'label' => 'hotpink', 2534 ), 2535 ), 2536 ), 2537 ), 2538 ), 2539 'custom' 2540 ); 2541 2542 $actual = $user->get_data(); 2543 $expected = array( 2544 'version' => 2, 2545 'settings' => array( 2546 'color' => array( 2547 'palette' => array( 2548 array( 2549 'slug' => 'white', 2550 'color' => '#fff', 2551 'label' => 'User White', 2552 ), 2553 array( 2554 'slug' => 'hotpink', 2555 'color' => 'hotpink', 2556 'label' => 'hotpink', 2557 ), 2558 ), 2559 ), 2560 ), 2561 ); 2562 2563 $this->assertEqualSetsWithIndex( $expected, $actual ); 2564 } 2565 2566 /** 2567 * @ticket 55505 2568 */ 2569 function test_export_data_deals_with_empty_data() { 2570 $theme_v2 = new WP_Theme_JSON( 2571 array( 2572 'version' => 2, 2573 ), 2574 'theme' 2575 ); 2576 $actual_v2 = $theme_v2->get_data(); 2577 $expected_v2 = array( 'version' => 2 ); 2578 $this->assertEqualSetsWithIndex( $expected_v2, $actual_v2 ); 2579 2580 $theme_v1 = new WP_Theme_JSON( 2581 array( 2582 'version' => 1, 2583 ), 2584 'theme' 2585 ); 2586 $actual_v1 = $theme_v1->get_data(); 2587 $expected_v1 = array( 'version' => 2 ); 2588 $this->assertEqualSetsWithIndex( $expected_v1, $actual_v1 ); 2589 } 2590 2591 /** 2592 * @ticket 55505 2593 */ 2594 function test_export_data_sets_appearance_tools() { 2595 $theme = new WP_Theme_JSON( 2596 array( 2597 'version' => 2, 2598 'settings' => array( 2599 'appearanceTools' => true, 2600 'blocks' => array( 2601 'core/paragraph' => array( 2602 'appearanceTools' => true, 2603 ), 2604 ), 2605 ), 2606 ) 2607 ); 2608 2609 $actual = $theme->get_data(); 2610 $expected = array( 2611 'version' => 2, 2612 'settings' => array( 2613 'appearanceTools' => true, 2614 'blocks' => array( 2615 'core/paragraph' => array( 2616 'appearanceTools' => true, 2617 ), 2618 ), 2619 ), 2620 ); 2621 2622 $this->assertEqualSetsWithIndex( $expected, $actual ); 2623 } 2387 2624 }
Note: See TracChangeset
for help on using the changeset viewer.