| 208 | * Test when a theme does not disable custom colors. |
| 209 | * |
| 210 | * @ticket 48798 |
| 211 | */ |
| 212 | public function test_theme_supports_disable_custom_colors_false() { |
| 213 | remove_theme_support( 'disable-custom-colors' ); |
| 214 | $response = self::perform_active_theme_request(); |
| 215 | $result = $response->get_data(); |
| 216 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 217 | $this->assertTrue( isset( $result[0]['theme_supports']['disable-custom-colors'] ) ); |
| 218 | $this->assertFalse( $result[0]['theme_supports']['disable-custom-colors'] ); |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Test when a theme disables custom colors. |
| 223 | * |
| 224 | * @ticket 48798 |
| 225 | */ |
| 226 | public function test_theme_supports_disable_custom_colors_true() { |
| 227 | remove_theme_support( 'disable-custom-colors' ); |
| 228 | add_theme_support( 'disable-custom-colors' ); |
| 229 | $response = self::perform_active_theme_request(); |
| 230 | $result = $response->get_data(); |
| 231 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 232 | $this->assertTrue( $result[0]['theme_supports']['disable-custom-colors'] ); |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Test when a theme does not disable custom font sizes. |
| 237 | * |
| 238 | * @ticket 48798 |
| 239 | */ |
| 240 | public function test_theme_supports_disable_custom_font_sizes_false() { |
| 241 | remove_theme_support( 'disable-custom-font-sizes' ); |
| 242 | $response = self::perform_active_theme_request(); |
| 243 | $result = $response->get_data(); |
| 244 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 245 | $this->assertTrue( isset( $result[0]['theme_supports']['disable-custom-font-sizes'] ) ); |
| 246 | $this->assertFalse( $result[0]['theme_supports']['disable-custom-font-sizes'] ); |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Test when a theme disables custom font sizes. |
| 251 | * |
| 252 | * @ticket 48798 |
| 253 | */ |
| 254 | public function test_theme_supports_disable_custom_font_sizes_true() { |
| 255 | remove_theme_support( 'disable-custom-font-sizes' ); |
| 256 | add_theme_support( 'disable-custom-font-sizes' ); |
| 257 | $response = self::perform_active_theme_request(); |
| 258 | $result = $response->get_data(); |
| 259 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 260 | $this->assertTrue( $result[0]['theme_supports']['disable-custom-font-sizes'] ); |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Test when a theme doesn't support custom font sizes. |
| 265 | * |
| 266 | * @ticket 48798 |
| 267 | */ |
| 268 | public function test_theme_supports_editor_font_sizes_false() { |
| 269 | remove_theme_support( 'editor-font-sizes' ); |
| 270 | $response = self::perform_active_theme_request(); |
| 271 | $result = $response->get_data(); |
| 272 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 273 | $this->assertTrue( isset( $result[0]['theme_supports']['editor-font-sizes'] ) ); |
| 274 | $this->assertFalse( $result[0]['theme_supports']['editor-font-sizes'] ); |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * Test when a theme supports custom font sizes. |
| 279 | * |
| 280 | * @ticket 48798 |
| 281 | */ |
| 282 | public function test_theme_supports_editor_font_sizes_array() { |
| 283 | remove_theme_support( 'editor-font-sizes' ); |
| 284 | $tiny = array( |
| 285 | 'name' => 'Tiny', |
| 286 | 'size' => 8, |
| 287 | 'slug' => 'tiny', |
| 288 | ); |
| 289 | add_theme_support( 'editor-font-sizes', array( $tiny ) ); |
| 290 | $response = self::perform_active_theme_request(); |
| 291 | $result = $response->get_data(); |
| 292 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 293 | $this->assertEquals( array( $tiny ), $result[0]['theme_supports']['editor-font-sizes'] ); |
| 294 | } |
| 295 | |
| 296 | /** |
| 297 | * Test when a theme doesn't support a custom color palette. |
| 298 | * |
| 299 | * @ticket 48798 |
| 300 | */ |
| 301 | public function test_theme_supports_editor_color_palette_false() { |
| 302 | remove_theme_support( 'editor-color-palette' ); |
| 303 | $response = self::perform_active_theme_request(); |
| 304 | $result = $response->get_data(); |
| 305 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 306 | $this->assertTrue( isset( $result[0]['theme_supports']['editor-color-palette'] ) ); |
| 307 | $this->assertFalse( $result[0]['theme_supports']['editor-color-palette'] ); |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Test when a theme supports a custom color palette. |
| 312 | * |
| 313 | * @ticket 48798 |
| 314 | */ |
| 315 | public function test_theme_supports_editor_color_palette_array() { |
| 316 | remove_theme_support( 'editor-color-palette' ); |
| 317 | $wordpress_blue = array( |
| 318 | 'name' => 'WordPress Blue', |
| 319 | 'slug' => 'wordpress-blue', |
| 320 | 'color' => '#0073AA', |
| 321 | ); |
| 322 | add_theme_support( 'editor-color-palette', array( $wordpress_blue ) ); |
| 323 | $response = self::perform_active_theme_request(); |
| 324 | $result = $response->get_data(); |
| 325 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 326 | $this->assertEquals( array( $wordpress_blue), $result[0]['theme_supports']['editor-color-palette'] ); |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * Test when a theme enables automatic feed links. |
| 331 | * |
| 332 | * @ticket 49037 |
| 333 | */ |
| 334 | public function test_theme_supports_enable_automatic_feed_links() { |
| 335 | remove_theme_support( 'automatic-feed-links' ); |
| 336 | add_theme_support( 'automatic-feed-links' ); |
| 337 | $response = self::perform_active_theme_request(); |
| 338 | $result = $response->get_data(); |
| 339 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 340 | $this->assertTrue( $result[0]['theme_supports']['automatic-feed-links'] ); |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * Test when a theme does not enable automatic feed links. |
| 345 | * |
| 346 | * @ticket 49037 |
| 347 | */ |
| 348 | public function test_theme_supports_does_not_enable_automatic_feed_links() { |
| 349 | remove_theme_support( 'automatic-feed-links' ); |
| 350 | $response = self::perform_active_theme_request(); |
| 351 | $result = $response->get_data(); |
| 352 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 353 | $this->assertTrue( isset( $result[0]['theme_supports']['automatic-feed-links'] ) ); |
| 354 | $this->assertFalse( $result[0]['theme_supports']['automatic-feed-links'] ); |
| 355 | } |
| 356 | |
| 357 | /** |
| 358 | * Test when a theme doesn't support a custom logo. |
| 359 | * |
| 360 | * @ticket 49037 |
| 361 | */ |
| 362 | public function test_theme_does_not_support_custom_logo() { |
| 363 | remove_theme_support( 'custom-logo' ); |
| 364 | $response = self::perform_active_theme_request(); |
| 365 | $result = $response->get_data(); |
| 366 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 367 | $this->assertTrue( isset( $result[0]['theme_supports']['custom-logo'] ) ); |
| 368 | $this->assertFalse( $result[0]['theme_supports']['custom-logo'] ); |
| 369 | } |
| 370 | |
| 371 | /** |
| 372 | * Test when a theme supports a custom logo. |
| 373 | * |
| 374 | * @ticket 49037 |
| 375 | */ |
| 376 | public function test_theme_supports_custom_logo() { |
| 377 | remove_theme_support( 'custom-logo' ); |
| 378 | $wordpress_logo = array( |
| 379 | 'height' => 100, |
| 380 | 'width' => 400, |
| 381 | 'flex-height' => true, |
| 382 | 'flex-width' => true, |
| 383 | 'header-text' => array( 'site-title', 'site-description' ), |
| 384 | ); |
| 385 | add_theme_support( 'custom-logo', $wordpress_logo ); |
| 386 | $response = self::perform_active_theme_request(); |
| 387 | $result = $response->get_data(); |
| 388 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 389 | $this->assertEquals( $wordpress_logo, $result[0]['theme_supports']['custom-logo'] ); |
| 390 | } |
| 391 | |
| 392 | /** |
| 393 | * Test when a theme doesn't support a custom header. |
| 394 | * |
| 395 | * @ticket 49037 |
| 396 | */ |
| 397 | public function test_theme_does_not_support_custom_header() { |
| 398 | remove_theme_support( 'custom-header' ); |
| 399 | $response = self::perform_active_theme_request(); |
| 400 | $result = $response->get_data(); |
| 401 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 402 | $this->assertTrue( isset( $result[0]['theme_supports']['custom-header'] ) ); |
| 403 | $this->assertFalse( $result[0]['theme_supports']['custom-header'] ); |
| 404 | } |
| 405 | |
| 406 | /** |
| 407 | * Test when a theme supports a custom header. |
| 408 | * |
| 409 | * @ticket 49037 |
| 410 | */ |
| 411 | public function test_theme_supports_custom_header() { |
| 412 | remove_theme_support( 'custom-header' ); |
| 413 | $wordpress_header = array( |
| 414 | 'default-image' => '', |
| 415 | 'random-default' => false, |
| 416 | 'width' => 0, |
| 417 | 'height' => 0, |
| 418 | 'flex-height' => false, |
| 419 | 'flex-width' => false, |
| 420 | 'default-text-color' => '', |
| 421 | 'header-text' => true, |
| 422 | 'uploads' => true, |
| 423 | 'wp-head-callback' => '', |
| 424 | 'admin-head-callback' => '', |
| 425 | 'admin-preview-callback' => '', |
| 426 | 'video' => false, |
| 427 | 'video-active-callback' => 'is_front_page', |
| 428 | ); |
| 429 | add_theme_support( 'custom-header', $wordpress_header ); |
| 430 | $response = self::perform_active_theme_request(); |
| 431 | $result = $response->get_data(); |
| 432 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 433 | $this->assertEquals( $wordpress_header, $result[0]['theme_supports']['custom-header'] ); |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * Test when a theme doesn't support html5 markup. |
| 438 | * |
| 439 | * @ticket 49037 |
| 440 | */ |
| 441 | public function test_theme_does_not_support_html5() { |
| 442 | remove_theme_support( 'html5' ); |
| 443 | $response = self::perform_active_theme_request(); |
| 444 | $result = $response->get_data(); |
| 445 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 446 | $this->assertTrue( isset( $result[0]['theme_supports']['html5'] ) ); |
| 447 | $this->assertFalse( $result[0]['theme_supports']['html5'] ); |
| 448 | } |
| 449 | |
| 450 | /** |
| 451 | * Test when a theme supports html5 markup. |
| 452 | * |
| 453 | * @ticket 49037 |
| 454 | */ |
| 455 | public function test_theme_supports_html5() { |
| 456 | remove_theme_support( 'html5' ); |
| 457 | $html5 = array( |
| 458 | 'search-form', |
| 459 | 'comment-form', |
| 460 | 'comment-list', |
| 461 | 'gallery', |
| 462 | 'caption', |
| 463 | 'script', |
| 464 | 'style', |
| 465 | ); |
| 466 | add_theme_support( 'html5', $html5 ); |
| 467 | $response = self::perform_active_theme_request(); |
| 468 | $result = $response->get_data(); |
| 469 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 470 | $this->assertEquals( $html5, $result[0]['theme_supports']['html5'] ); |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Test when a theme cannot manage title tag. |
| 475 | * |
| 476 | * @ticket 49037 |
| 477 | */ |
| 478 | public function test_theme_cannot_manage_title_tag() { |
| 479 | remove_theme_support( 'title-tag' ); |
| 480 | $response = self::perform_active_theme_request(); |
| 481 | $result = $response->get_data(); |
| 482 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 483 | $this->assertTrue( isset( $result[0]['theme_supports']['title-tag'] ) ); |
| 484 | $this->assertFalse( $result[0]['theme_supports']['title-tag'] ); |
| 485 | } |
| 486 | |
| 487 | /** |
| 488 | * Test when a theme can mange title tag. |
| 489 | * |
| 490 | * @ticket 49037 |
| 491 | */ |
| 492 | public function test_theme_can_manage_title_tag() { |
| 493 | remove_theme_support( 'title-tag' ); |
| 494 | add_theme_support( 'title-tag' ); |
| 495 | $response = self::perform_active_theme_request(); |
| 496 | $result = $response->get_data(); |
| 497 | global $_wp_theme_features; |
| 498 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 499 | $this->assertTrue( $result[0]['theme_supports']['title-tag'] ); |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * Test when a theme cannot manage Selective Refresh for Widgets. |
| 504 | * |
| 505 | * @ticket 49037 |
| 506 | */ |
| 507 | public function test_theme_cannot_manage_selective_refresh_for_widgets() { |
| 508 | remove_theme_support( 'customize-selective-refresh-widgets' ); |
| 509 | $response = self::perform_active_theme_request(); |
| 510 | $result = $response->get_data(); |
| 511 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 512 | $this->assertTrue( isset( $result[0]['theme_supports']['customize-selective-refresh-widgets'] ) ); |
| 513 | $this->assertFalse( $result[0]['theme_supports']['customize-selective-refresh-widgets'] ); |
| 514 | } |
| 515 | |
| 516 | /** |
| 517 | * Test when a theme can mange Selective Refresh for Widgets. |
| 518 | * |
| 519 | * @ticket 49037 |
| 520 | */ |
| 521 | public function test_theme_can_manage_selective_refresh_for_widgets() { |
| 522 | remove_theme_support( 'customize-selective-refresh-widgets' ); |
| 523 | add_theme_support( 'customize-selective-refresh-widgets' ); |
| 524 | $response = self::perform_active_theme_request(); |
| 525 | $result = $response->get_data(); |
| 526 | $this->assertTrue( isset( $result[0]['theme_supports'] ) ); |
| 527 | $this->assertTrue( $result[0]['theme_supports']['customize-selective-refresh-widgets'] ); |
| 528 | } |
| 529 | |
| 530 | /** |