Skip to content

Commit 45cf478

Browse files
Tests: Use the ms-required group where appropriate.
This replaces the `if ( is_multisite() )` conditional wrapping entire test classes with the `ms-required` group for more consistency across the test suite. Follow-up to [40520]. See #63167. git-svn-id: https://develop.svn.wordpress.org/trunk@60148 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ac648a1 commit 45cf478

36 files changed

+8079
-8149
lines changed
Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,67 @@
11
<?php
22

3-
if ( is_multisite() ) :
3+
/**
4+
* Tests specific to `avoid_blog_page_permalink_collision()` in multisite.
5+
*
6+
* @group ms-required
7+
* @group multisite
8+
* @group post
9+
*/
10+
class Tests_Multisite_AvoidBlogPagePermalinkCollision extends WP_UnitTestCase {
11+
12+
protected static $site_id;
13+
protected static $root_page;
14+
protected static $child_page;
15+
protected static $post_and_blog_path = 'permalink-collision';
416

517
/**
6-
* Tests specific to `avoid_blog_page_permalink_collision()` in multisite.
7-
*
8-
* @group multisite
9-
* @group post
18+
* Create a blog and the pages we need to test the collision.
1019
*/
11-
class Tests_Multisite_AvoidBlogPagePermalinkCollision extends WP_UnitTestCase {
12-
protected static $site_id;
13-
protected static $root_page;
14-
protected static $child_page;
15-
protected static $post_and_blog_path = 'permalink-collision';
16-
17-
/**
18-
* Create a blog and the pages we need to test the collision.
19-
*/
20-
public static function wpSetUpBeforeClass( $factory ) {
21-
self::$site_id = self::factory()->blog->create(
22-
array(
23-
'path' => '/' . self::$post_and_blog_path,
24-
)
25-
);
20+
public static function wpSetUpBeforeClass( $factory ) {
21+
self::$site_id = self::factory()->blog->create(
22+
array(
23+
'path' => '/' . self::$post_and_blog_path,
24+
)
25+
);
2626

27-
self::$root_page = self::factory()->post->create_and_get(
28-
array(
29-
'post_type' => 'page',
30-
'post_title' => 'Bar',
31-
'post_name' => self::$post_and_blog_path,
32-
)
33-
);
27+
self::$root_page = self::factory()->post->create_and_get(
28+
array(
29+
'post_type' => 'page',
30+
'post_title' => 'Bar',
31+
'post_name' => self::$post_and_blog_path,
32+
)
33+
);
3434

35-
self::$child_page = self::factory()->post->create_and_get(
36-
array(
37-
'post_parent' => self::$root_page->ID,
38-
'post_type' => 'page',
39-
'post_title' => 'Bar',
40-
'post_name' => self::$post_and_blog_path,
41-
)
42-
);
43-
}
44-
45-
/**
46-
* Delete blog and pages we created.
47-
*/
48-
public static function wpTearDownAfterClass() {
49-
wp_delete_site( self::$site_id );
35+
self::$child_page = self::factory()->post->create_and_get(
36+
array(
37+
'post_parent' => self::$root_page->ID,
38+
'post_type' => 'page',
39+
'post_title' => 'Bar',
40+
'post_name' => self::$post_and_blog_path,
41+
)
42+
);
43+
}
5044

51-
wp_delete_post( self::$root_page->ID );
52-
wp_delete_post( self::$child_page->ID );
53-
}
45+
/**
46+
* Delete blog and pages we created.
47+
*/
48+
public static function wpTearDownAfterClass() {
49+
wp_delete_site( self::$site_id );
5450

55-
public function test_avoid_blog_page_permalink_collision_renames_post_name() {
56-
$this->assertNotSame( self::$post_and_blog_path, self::$root_page->post_name );
57-
}
51+
wp_delete_post( self::$root_page->ID );
52+
wp_delete_post( self::$child_page->ID );
53+
}
5854

59-
/**
60-
* Ensure `avoid_blog_page_permalink_collision()` doesn't rename child pages' post_name.
61-
*
62-
* @ticket 51147
63-
*/
64-
public function test_avoid_blog_page_permalink_collision_doesnt_rename_child_pages() {
65-
$this->assertSame( self::$post_and_blog_path, self::$child_page->post_name );
66-
}
55+
public function test_avoid_blog_page_permalink_collision_renames_post_name() {
56+
$this->assertNotSame( self::$post_and_blog_path, self::$root_page->post_name );
6757
}
6858

69-
endif;
59+
/**
60+
* Ensure `avoid_blog_page_permalink_collision()` doesn't rename child pages' post_name.
61+
*
62+
* @ticket 51147
63+
*/
64+
public function test_avoid_blog_page_permalink_collision_doesnt_rename_child_pages() {
65+
$this->assertSame( self::$post_and_blog_path, self::$child_page->post_name );
66+
}
67+
}

0 commit comments

Comments
 (0)