Skip to content

Commit b99e49d

Browse files
committed
Tests: Cover wp_admin_css_uri().
Verify that `wp_admin_css_uri()` returns the admin stylesheet URL with a version argument, and that the `wp_admin_css_uri` filter receives the file name and can replace the URL. Developed in: #15364 Props devmuhib, huzaifaalmesbah. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65236 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6b38a21 commit b99e49d

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Test wp_admin_css_uri().
4+
*
5+
* @group general
6+
* @group template
7+
*
8+
* @covers ::wp_admin_css_uri
9+
*/
10+
class Tests_General_wpAdminCssUri extends WP_UnitTestCase {
11+
12+
/**
13+
* Tests wp_admin_css_uri() returns the admin stylesheet URI with version parameter.
14+
*
15+
* @ticket 65819
16+
*/
17+
public function test_wp_admin_css_uri() {
18+
$uri = wp_admin_css_uri();
19+
20+
$this->assertStringStartsWith( admin_url( 'wp-admin.css' ), $uri );
21+
$this->assertStringContainsString( 'version=' . get_bloginfo( 'version' ), $uri );
22+
}
23+
24+
/**
25+
* Tests that 'wp_admin_css_uri' filter can modify the returned URI and receives expected arguments.
26+
*
27+
* @ticket 65819
28+
*/
29+
public function test_wp_admin_css_uri_filter() {
30+
$received_file = null;
31+
32+
$callback = function ( $uri, $file ) use ( &$received_file ) {
33+
$received_file = $file;
34+
return 'https://example.org/filtered-admin.css';
35+
};
36+
37+
add_filter( 'wp_admin_css_uri', $callback, 10, 2 );
38+
$actual = wp_admin_css_uri( 'custom-admin' );
39+
40+
$this->assertSame( 'custom-admin', $received_file );
41+
$this->assertSame( 'https://example.org/filtered-admin.css', $actual );
42+
}
43+
}

0 commit comments

Comments
 (0)