• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress develop tests

WordPress develop tests

WordPress develop tests a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Test_WP_Customize_Custom_CSS_Setting::test_validate() – Tests that validation errors are caught appropriately.

You appear to be a bot. Output may be restricted

Description

Tests that validation errors are caught appropriately.

Note that the $validity \WP_Error object must be reset each time as it picks up the Errors and passes them to the next assertion.

Usage

Test_WP_Customize_Custom_CSS_Setting::test_validate();

Parameters

Returns

void

Source

File name: wordpress-develop-tests/phpunit/tests/customize/custom-css-setting.php


Lines:

1 to 17 of 17
  public function test_validate() {

    // Empty CSS throws no errors.
    $result = $this->setting->validate( '' );
    $this->assertTrue( $result );

    // Basic, valid CSS throws no errors.
    $basic_css = 'body { background: #f00; } h1.site-title { font-size: 36px; } a:hover { text-decoration: none; } input[type="text"] { padding: 1em; }';
    $result    = $this->setting->validate( $basic_css );
    $this->assertTrue( $result );

    // Check for markup.
    $unclosed_comment = $basic_css . '</style>';
    $result           = $this->setting->validate( $unclosed_comment );
    $this->assertArrayHasKey( 'illegal_markup', $result->errors );
  }
 

 View on GitHub

Published: 26th November 2019 | Last updated: 20th March 2022

Primary Sidebar

Information

Function name: Test_WP_Customize_Custom_CSS_Setting::test_validate
Class ref: Test_WP_Customize_Custom_CSS_Setting
Plugin ref: WordPress develop tests
Version: 5.9.3
Sourcefile: phpunit/tests/customize/custom-css-setting.php
File ref: phpunit/tests/customize/custom-css-setting.php
Deprecated?: No
API Letters: C,T,W

Footer

WordPress develop tests
WordPress develop tests
WordPress develop tests a2z
WordPress 6.3.1
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  develop.wp-a2z.org
© Copyright WordPress develop tests 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites