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 ); }