| | 207 | $this->assertArrayHasKey( 'title-tag', $properties['theme_supports']['properties'] ); |
| | 208 | $this->assertArrayHasKey( 'wp-block-styles', $properties['theme_supports']['properties'] ); |
| | 209 | } |
| | 210 | |
| | 211 | /** |
| | 212 | * Test when a theme does not disable custom colors. |
| | 213 | * |
| | 214 | * @ticket 48798 |
| | 215 | */ |
| | 216 | public function test_theme_supports_disable_custom_colors_false() { |
| | 217 | remove_theme_support( 'disable-custom-colors' ); |
| | 218 | $response = self::perform_active_theme_request(); |
| | 219 | $result = $response->get_data(); |
| | 220 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 221 | $this->assertTrue( isset( $result[0]['theme_supports']['disable-custom-colors'] ) ); |
| | 222 | $this->assertFalse( $result[0]['theme_supports']['disable-custom-colors'] ); |
| | 223 | } |
| | 224 | |
| | 225 | /** |
| | 226 | * Test when a theme disables custom colors. |
| | 227 | * |
| | 228 | * @ticket 48798 |
| | 229 | */ |
| | 230 | public function test_theme_supports_disable_custom_colors_true() { |
| | 231 | remove_theme_support( 'disable-custom-colors' ); |
| | 232 | add_theme_support( 'disable-custom-colors' ); |
| | 233 | $response = self::perform_active_theme_request(); |
| | 234 | $result = $response->get_data(); |
| | 235 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 236 | $this->assertTrue( $result[0]['theme_supports']['disable-custom-colors'] ); |
| | 237 | } |
| | 238 | |
| | 239 | /** |
| | 240 | * Test when a theme does not disable custom font sizes. |
| | 241 | * |
| | 242 | * @ticket 48798 |
| | 243 | */ |
| | 244 | public function test_theme_supports_disable_custom_font_sizes_false() { |
| | 245 | remove_theme_support( 'disable-custom-font-sizes' ); |
| | 246 | $response = self::perform_active_theme_request(); |
| | 247 | $result = $response->get_data(); |
| | 248 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 249 | $this->assertTrue( isset( $result[0]['theme_supports']['disable-custom-font-sizes'] ) ); |
| | 250 | $this->assertFalse( $result[0]['theme_supports']['disable-custom-font-sizes'] ); |
| | 251 | } |
| | 252 | |
| | 253 | /** |
| | 254 | * Test when a theme disables custom font sizes. |
| | 255 | * |
| | 256 | * @ticket 48798 |
| | 257 | */ |
| | 258 | public function test_theme_supports_disable_custom_font_sizes_true() { |
| | 259 | remove_theme_support( 'disable-custom-font-sizes' ); |
| | 260 | add_theme_support( 'disable-custom-font-sizes' ); |
| | 261 | $response = self::perform_active_theme_request(); |
| | 262 | $result = $response->get_data(); |
| | 263 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 264 | $this->assertTrue( $result[0]['theme_supports']['disable-custom-font-sizes'] ); |
| | 265 | } |
| | 266 | |
| | 267 | /** |
| | 268 | * Test when a theme doesn't support custom font sizes. |
| | 269 | * |
| | 270 | * @ticket 48798 |
| | 271 | */ |
| | 272 | public function test_theme_supports_editor_font_sizes_false() { |
| | 273 | remove_theme_support( 'editor-font-sizes' ); |
| | 274 | $response = self::perform_active_theme_request(); |
| | 275 | $result = $response->get_data(); |
| | 276 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 277 | $this->assertTrue( isset( $result[0]['theme_supports']['editor-font-sizes'] ) ); |
| | 278 | $this->assertFalse( $result[0]['theme_supports']['editor-font-sizes'] ); |
| | 279 | } |
| | 280 | |
| | 281 | /** |
| | 282 | * Test when a theme supports custom font sizes. |
| | 283 | * |
| | 284 | * @ticket 48798 |
| | 285 | */ |
| | 286 | public function test_theme_supports_editor_font_sizes_array() { |
| | 287 | remove_theme_support( 'editor-font-sizes' ); |
| | 288 | $tiny = array( |
| | 289 | 'name' => 'Tiny', |
| | 290 | 'size' => 8, |
| | 291 | 'slug' => 'tiny', |
| | 292 | ); |
| | 293 | add_theme_support( 'editor-font-sizes', array( $tiny ) ); |
| | 294 | $response = self::perform_active_theme_request(); |
| | 295 | $result = $response->get_data(); |
| | 296 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 297 | $this->assertEquals( array( $tiny ), $result[0]['theme_supports']['editor-font-sizes'] ); |
| | 298 | } |
| | 299 | |
| | 300 | /** |
| | 301 | * Test when a theme doesn't support a custom color palette. |
| | 302 | * |
| | 303 | * @ticket 48798 |
| | 304 | */ |
| | 305 | public function test_theme_supports_editor_color_palette_false() { |
| | 306 | remove_theme_support( 'editor-color-palette' ); |
| | 307 | $response = self::perform_active_theme_request(); |
| | 308 | $result = $response->get_data(); |
| | 309 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 310 | $this->assertTrue( isset( $result[0]['theme_supports']['editor-color-palette'] ) ); |
| | 311 | $this->assertFalse( $result[0]['theme_supports']['editor-color-palette'] ); |
| | 312 | } |
| | 313 | |
| | 314 | /** |
| | 315 | * Test when a theme supports a custom color palette. |
| | 316 | * |
| | 317 | * @ticket 48798 |
| | 318 | */ |
| | 319 | public function test_theme_supports_editor_color_palette_array() { |
| | 320 | remove_theme_support( 'editor-color-palette' ); |
| | 321 | $wordpress_blue = array( |
| | 322 | 'name' => 'WordPress Blue', |
| | 323 | 'slug' => 'wordpress-blue', |
| | 324 | 'color' => '#0073AA', |
| | 325 | ); |
| | 326 | add_theme_support( 'editor-color-palette', array( $wordpress_blue ) ); |
| | 327 | $response = self::perform_active_theme_request(); |
| | 328 | $result = $response->get_data(); |
| | 329 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 330 | $this->assertEquals( array( $wordpress_blue ), $result[0]['theme_supports']['editor-color-palette'] ); |
| | 331 | } |
| | 332 | |
| | 333 | /** |
| | 334 | * Test when a theme enables automatic feed links. |
| | 335 | * |
| | 336 | * @ticket 49037 |
| | 337 | */ |
| | 338 | public function test_theme_supports_enable_automatic_feed_links() { |
| | 339 | remove_theme_support( 'automatic-feed-links' ); |
| | 340 | add_theme_support( 'automatic-feed-links' ); |
| | 341 | $response = self::perform_active_theme_request(); |
| | 342 | $result = $response->get_data(); |
| | 343 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 344 | $this->assertTrue( $result[0]['theme_supports']['automatic-feed-links'] ); |
| | 345 | } |
| | 346 | |
| | 347 | /** |
| | 348 | * Test when a theme does not enable automatic feed links. |
| | 349 | * |
| | 350 | * @ticket 49037 |
| | 351 | */ |
| | 352 | public function test_theme_supports_does_not_enable_automatic_feed_links() { |
| | 353 | remove_theme_support( 'automatic-feed-links' ); |
| | 354 | $response = self::perform_active_theme_request(); |
| | 355 | $result = $response->get_data(); |
| | 356 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 357 | $this->assertTrue( isset( $result[0]['theme_supports']['automatic-feed-links'] ) ); |
| | 358 | $this->assertFalse( $result[0]['theme_supports']['automatic-feed-links'] ); |
| | 359 | } |
| | 360 | |
| | 361 | /** |
| | 362 | * Test when a theme doesn't support a custom logo. |
| | 363 | * |
| | 364 | * @ticket 49037 |
| | 365 | */ |
| | 366 | public function test_theme_does_not_support_custom_logo() { |
| | 367 | remove_theme_support( 'custom-logo' ); |
| | 368 | $response = self::perform_active_theme_request(); |
| | 369 | $result = $response->get_data(); |
| | 370 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 371 | $this->assertTrue( isset( $result[0]['theme_supports']['custom-logo'] ) ); |
| | 372 | $this->assertFalse( $result[0]['theme_supports']['custom-logo'] ); |
| | 373 | } |
| | 374 | |
| | 375 | /** |
| | 376 | * Test when a theme supports a custom logo. |
| | 377 | * |
| | 378 | * @ticket 49037 |
| | 379 | */ |
| | 380 | public function test_theme_supports_custom_logo() { |
| | 381 | remove_theme_support( 'custom-logo' ); |
| | 382 | $wordpress_logo = array( |
| | 383 | 'height' => 100, |
| | 384 | 'width' => 400, |
| | 385 | 'flex-height' => true, |
| | 386 | 'flex-width' => true, |
| | 387 | 'header-text' => array( 'site-title', 'site-description' ), |
| | 388 | ); |
| | 389 | add_theme_support( 'custom-logo', $wordpress_logo ); |
| | 390 | $response = self::perform_active_theme_request(); |
| | 391 | $result = $response->get_data(); |
| | 392 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 393 | $this->assertEquals( $wordpress_logo, $result[0]['theme_supports']['custom-logo'] ); |
| | 394 | } |
| | 395 | |
| | 396 | /** |
| | 397 | * Test when a theme doesn't support a custom header. |
| | 398 | * |
| | 399 | * @ticket 49037 |
| | 400 | */ |
| | 401 | public function test_theme_does_not_support_custom_header() { |
| | 402 | remove_theme_support( 'custom-header' ); |
| | 403 | $response = self::perform_active_theme_request(); |
| | 404 | $result = $response->get_data(); |
| | 405 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 406 | $this->assertTrue( isset( $result[0]['theme_supports']['custom-header'] ) ); |
| | 407 | $this->assertFalse( $result[0]['theme_supports']['custom-header'] ); |
| | 408 | } |
| | 409 | |
| | 410 | /** |
| | 411 | * Test when a theme supports a custom header. |
| | 412 | * |
| | 413 | * @ticket 49037 |
| | 414 | */ |
| | 415 | public function test_theme_supports_custom_header() { |
| | 416 | remove_theme_support( 'custom-header' ); |
| | 417 | $wordpress_header = array( |
| | 418 | 'default-image' => '', |
| | 419 | 'random-default' => false, |
| | 420 | 'width' => 0, |
| | 421 | 'height' => 0, |
| | 422 | 'flex-height' => false, |
| | 423 | 'flex-width' => false, |
| | 424 | 'default-text-color' => '', |
| | 425 | 'header-text' => true, |
| | 426 | 'uploads' => true, |
| | 427 | 'wp-head-callback' => '', |
| | 428 | 'admin-head-callback' => '', |
| | 429 | 'admin-preview-callback' => '', |
| | 430 | 'video' => false, |
| | 431 | 'video-active-callback' => 'is_front_page', |
| | 432 | ); |
| | 433 | add_theme_support( 'custom-header', $wordpress_header ); |
| | 434 | $response = self::perform_active_theme_request(); |
| | 435 | $result = $response->get_data(); |
| | 436 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 437 | $this->assertEquals( $wordpress_header, $result[0]['theme_supports']['custom-header'] ); |
| | 438 | } |
| | 439 | |
| | 440 | /** |
| | 441 | * Test when a theme doesn't support html5 markup. |
| | 442 | * |
| | 443 | * @ticket 49037 |
| | 444 | */ |
| | 445 | public function test_theme_does_not_support_html5() { |
| | 446 | remove_theme_support( 'html5' ); |
| | 447 | $response = self::perform_active_theme_request(); |
| | 448 | $result = $response->get_data(); |
| | 449 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 450 | $this->assertTrue( isset( $result[0]['theme_supports']['html5'] ) ); |
| | 451 | $this->assertFalse( $result[0]['theme_supports']['html5'] ); |
| | 452 | } |
| | 453 | |
| | 454 | /** |
| | 455 | * Test when a theme supports html5 markup. |
| | 456 | * |
| | 457 | * @ticket 49037 |
| | 458 | */ |
| | 459 | public function test_theme_supports_html5() { |
| | 460 | remove_theme_support( 'html5' ); |
| | 461 | $html5 = array( |
| | 462 | 'search-form', |
| | 463 | 'comment-form', |
| | 464 | 'comment-list', |
| | 465 | 'gallery', |
| | 466 | 'caption', |
| | 467 | 'script', |
| | 468 | 'style', |
| | 469 | ); |
| | 470 | add_theme_support( 'html5', $html5 ); |
| | 471 | $response = self::perform_active_theme_request(); |
| | 472 | $result = $response->get_data(); |
| | 473 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 474 | $this->assertEquals( $html5, $result[0]['theme_supports']['html5'] ); |
| | 475 | } |
| | 476 | |
| | 477 | /** |
| | 478 | * Test when a theme cannot manage title tag. |
| | 479 | * |
| | 480 | * @ticket 49037 |
| | 481 | */ |
| | 482 | public function test_theme_cannot_manage_title_tag() { |
| | 483 | remove_theme_support( 'title-tag' ); |
| | 484 | $response = self::perform_active_theme_request(); |
| | 485 | $result = $response->get_data(); |
| | 486 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 487 | $this->assertTrue( isset( $result[0]['theme_supports']['title-tag'] ) ); |
| | 488 | $this->assertFalse( $result[0]['theme_supports']['title-tag'] ); |
| | 489 | } |
| | 490 | |
| | 491 | /** |
| | 492 | * Test when a theme can manage title tag. |
| | 493 | * |
| | 494 | * @ticket 49037 |
| | 495 | */ |
| | 496 | public function test_theme_can_manage_title_tag() { |
| | 497 | global $_wp_theme_features; |
| | 498 | $_wp_theme_features['title-tag'] = true; |
| | 499 | $response = self::perform_active_theme_request(); |
| | 500 | $result = $response->get_data(); |
| | 501 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 502 | $this->assertTrue( $result[0]['theme_supports']['title-tag'] ); |
| | 503 | } |
| | 504 | |
| | 505 | /** |
| | 506 | * Test when a theme cannot manage Selective Refresh for Widgets. |
| | 507 | * |
| | 508 | * @ticket 49037 |
| | 509 | */ |
| | 510 | public function test_theme_cannot_manage_selective_refresh_for_widgets() { |
| | 511 | remove_theme_support( 'customize-selective-refresh-widgets' ); |
| | 512 | $response = self::perform_active_theme_request(); |
| | 513 | $result = $response->get_data(); |
| | 514 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 515 | $this->assertTrue( isset( $result[0]['theme_supports']['customize-selective-refresh-widgets'] ) ); |
| | 516 | $this->assertFalse( $result[0]['theme_supports']['customize-selective-refresh-widgets'] ); |
| | 517 | } |
| | 518 | |
| | 519 | /** |
| | 520 | * Test when a theme can mange Selective Refresh for Widgets. |
| | 521 | * |
| | 522 | * @ticket 49037 |
| | 523 | */ |
| | 524 | public function test_theme_can_manage_selective_refresh_for_widgets() { |
| | 525 | remove_theme_support( 'customize-selective-refresh-widgets' ); |
| | 526 | add_theme_support( 'customize-selective-refresh-widgets' ); |
| | 527 | $response = self::perform_active_theme_request(); |
| | 528 | $result = $response->get_data(); |
| | 529 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 530 | $this->assertTrue( $result[0]['theme_supports']['customize-selective-refresh-widgets'] ); |
| | 531 | } |
| | 532 | |
| | 533 | /** |
| | 534 | * Test when a theme does not opt in to the default block styles for viewing. |
| | 535 | * |
| | 536 | * @ticket 49037 |
| | 537 | */ |
| | 538 | public function test_theme_no_wp_block_styles() { |
| | 539 | remove_theme_support( 'wp-block-styles' ); |
| | 540 | $response = self::perform_active_theme_request(); |
| | 541 | $result = $response->get_data(); |
| | 542 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 543 | $this->assertTrue( isset( $result[0]['theme_supports']['wp-block-styles'] ) ); |
| | 544 | $this->assertFalse( $result[0]['theme_supports']['wp-block-styles'] ); |
| | 545 | } |
| | 546 | |
| | 547 | /** |
| | 548 | * Test when a theme opts in to the default block styles for viewing. |
| | 549 | * |
| | 550 | * @ticket 49037 |
| | 551 | */ |
| | 552 | public function test_theme_wp_block_styles_optin() { |
| | 553 | remove_theme_support( 'wp-block-styles' ); |
| | 554 | add_theme_support( 'wp-block-styles' ); |
| | 555 | $response = self::perform_active_theme_request(); |
| | 556 | $result = $response->get_data(); |
| | 557 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 558 | $this->assertTrue( $result[0]['theme_supports']['wp-block-styles'] ); |
| | 559 | } |
| | 560 | |
| | 561 | /** |
| | 562 | * Test when a theme does not opt in to wide alignment CSS class. |
| | 563 | * |
| | 564 | * @ticket 49037 |
| | 565 | */ |
| | 566 | public function test_theme_no_align_wide() { |
| | 567 | remove_theme_support( 'align-wide' ); |
| | 568 | $response = self::perform_active_theme_request(); |
| | 569 | $result = $response->get_data(); |
| | 570 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 571 | $this->assertTrue( isset( $result[0]['theme_supports']['align-wide'] ) ); |
| | 572 | $this->assertFalse( $result[0]['theme_supports']['align-wide'] ); |
| | 573 | } |
| | 574 | |
| | 575 | /** |
| | 576 | * Test when a theme opts in to wide alignment CSS class. |
| | 577 | * |
| | 578 | * @ticket 49037 |
| | 579 | */ |
| | 580 | public function test_theme_align_wide_optin() { |
| | 581 | remove_theme_support( 'align-wide' ); |
| | 582 | add_theme_support( 'align-wide' ); |
| | 583 | $response = self::perform_active_theme_request(); |
| | 584 | $result = $response->get_data(); |
| | 585 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 586 | $this->assertTrue( $result[0]['theme_supports']['align-wide'] ); |
| | 587 | } |
| | 588 | |
| | 589 | /** |
| | 590 | * Test when a theme does not opt in to the editor styles CSS wrapper. |
| | 591 | * |
| | 592 | * @ticket 49037 |
| | 593 | */ |
| | 594 | public function test_theme_no_editor_styles() { |
| | 595 | remove_theme_support( 'editor-styles' ); |
| | 596 | $response = self::perform_active_theme_request(); |
| | 597 | $result = $response->get_data(); |
| | 598 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 599 | $this->assertTrue( isset( $result[0]['theme_supports']['editor-styles'] ) ); |
| | 600 | $this->assertFalse( $result[0]['theme_supports']['editor-styles'] ); |
| | 601 | } |
| | 602 | |
| | 603 | /** |
| | 604 | * Test when a theme opts in to the editor styles CSS wrapper. |
| | 605 | * |
| | 606 | * @ticket 49037 |
| | 607 | */ |
| | 608 | public function test_theme_editor_styles_optin() { |
| | 609 | remove_theme_support( 'editor-styles' ); |
| | 610 | add_theme_support( 'editor-styles' ); |
| | 611 | $response = self::perform_active_theme_request(); |
| | 612 | $result = $response->get_data(); |
| | 613 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 614 | $this->assertTrue( $result[0]['theme_supports']['editor-styles'] ); |
| | 615 | } |
| | 616 | |
| | 617 | /** |
| | 618 | * Test when a theme does not opt in to the dark editor style UI. |
| | 619 | * |
| | 620 | * @ticket 49037 |
| | 621 | */ |
| | 622 | public function test_theme_no_dark_editor_style() { |
| | 623 | remove_theme_support( 'dark-editor-style' ); |
| | 624 | $response = self::perform_active_theme_request(); |
| | 625 | $result = $response->get_data(); |
| | 626 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 627 | $this->assertTrue( isset( $result[0]['theme_supports']['dark-editor-style'] ) ); |
| | 628 | $this->assertFalse( $result[0]['theme_supports']['dark-editor-style'] ); |
| | 629 | } |
| | 630 | |
| | 631 | /** |
| | 632 | * Test when a theme opts in to the dark editor style UI. |
| | 633 | * |
| | 634 | * @ticket 49037 |
| | 635 | */ |
| | 636 | public function test_theme_dark_editor_style_optin() { |
| | 637 | remove_theme_support( 'dark-editor-style' ); |
| | 638 | add_theme_support( 'dark-editor-style' ); |
| | 639 | $response = self::perform_active_theme_request(); |
| | 640 | $result = $response->get_data(); |
| | 641 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| | 642 | $this->assertTrue( $result[0]['theme_supports']['dark-editor-style'] ); |