Skip to content

Commit 5ddc196

Browse files
Tests: Split the admin/includesMisc.php test file to match the new pattern.
This aims to make the test suite directory and file structure more intuitive for new contributors to work with, as well as follow the PHPUnit recommended test class name pattern with having `Test` as the end of the class name. Follow-up to [434/tests], [57283]. See #53010. git-svn-id: https://develop.svn.wordpress.org/trunk@62313 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 263d8ee commit 5ddc196

2 files changed

Lines changed: 39 additions & 31 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/**
4+
* @group admin
5+
*
6+
* @covers ::update_option_new_admin_email
7+
*/
8+
class Admin_Includes_Misc_UpdateOptioNewAdminEmail_Test extends WP_UnitTestCase {
9+
10+
/**
11+
* @ticket 59520
12+
*/
13+
public function test_new_admin_email_subject_filter() {
14+
// Default value.
15+
$mailer = tests_retrieve_phpmailer_instance();
16+
update_option_new_admin_email( 'old@example.com', 'new@example.com' );
17+
$this->assertSame( '[Test Blog] New Admin Email Address', $mailer->get_sent()->subject );
18+
19+
// Filtered value.
20+
add_filter(
21+
'new_admin_email_subject',
22+
function () {
23+
return 'Filtered Admin Email Address';
24+
},
25+
10,
26+
1
27+
);
28+
29+
$mailer->mock_sent = array();
30+
31+
$mailer = tests_retrieve_phpmailer_instance();
32+
update_option_new_admin_email( 'old@example.com', 'new@example.com' );
33+
$this->assertSame( 'Filtered Admin Email Address', $mailer->get_sent()->subject );
34+
}
35+
}

tests/phpunit/tests/admin/includesMisc.php renamed to tests/phpunit/tests/admin/Admin_Includes_Misc_UrlShorten_Test.php

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
/**
44
* @group admin
5+
*
6+
* @covers ::url_shorten
57
*/
6-
class Tests_Admin_IncludesMisc extends WP_UnitTestCase {
8+
class Admin_Includes_Misc_UrlShorten_Test extends WP_UnitTestCase {
79

8-
/**
9-
* @covers ::url_shorten
10-
*/
11-
public function test_shorten_url() {
10+
public function test_url_shorten() {
1211
$tests = array(
1312
'wordpress\.org/about/philosophy'
1413
=> 'wordpress\.org/about/philosophy', // No longer strips slashes.
@@ -27,30 +26,4 @@ public function test_shorten_url() {
2726
$this->assertSame( $v, url_shorten( $k ) );
2827
}
2928
}
30-
31-
/**
32-
* @ticket 59520
33-
*/
34-
public function test_new_admin_email_subject_filter() {
35-
// Default value.
36-
$mailer = tests_retrieve_phpmailer_instance();
37-
update_option_new_admin_email( 'old@example.com', 'new@example.com' );
38-
$this->assertSame( '[Test Blog] New Admin Email Address', $mailer->get_sent()->subject );
39-
40-
// Filtered value.
41-
add_filter(
42-
'new_admin_email_subject',
43-
function () {
44-
return 'Filtered Admin Email Address';
45-
},
46-
10,
47-
1
48-
);
49-
50-
$mailer->mock_sent = array();
51-
52-
$mailer = tests_retrieve_phpmailer_instance();
53-
update_option_new_admin_email( 'old@example.com', 'new@example.com' );
54-
$this->assertSame( 'Filtered Admin Email Address', $mailer->get_sent()->subject );
55-
}
5629
}

0 commit comments

Comments
 (0)