Skip to content

Commit b7a0ae1

Browse files
author
costdev
committed
Add tests for WP_MS_Users_List_Table::get_views().
1 parent e51ba8d commit b7a0ae1

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
3+
if ( is_multisite() ) :
4+
5+
/**
6+
* @group admin
7+
* @group network-admin
8+
*
9+
* @covers WP_MS_Users_List_Table
10+
*/
11+
class Tests_Multisite_wpMsUsersListTable extends WP_UnitTestCase {
12+
protected static $site_ids;
13+
14+
/**
15+
* @var WP_MS_Users_List_Table
16+
*/
17+
public $table = false;
18+
19+
public function set_up() {
20+
parent::set_up();
21+
$this->table = _get_list_table( 'WP_MS_Users_List_Table', array( 'screen' => 'ms-users' ) );
22+
}
23+
24+
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
25+
self::$site_ids = array(
26+
'wordpress.org/' => array(
27+
'domain' => 'wordpress.org',
28+
'path' => '/',
29+
),
30+
'wordpress.org/foo/' => array(
31+
'domain' => 'wordpress.org',
32+
'path' => '/foo/',
33+
),
34+
'wordpress.org/foo/bar/' => array(
35+
'domain' => 'wordpress.org',
36+
'path' => '/foo/bar/',
37+
),
38+
'wordpress.org/afoo/' => array(
39+
'domain' => 'wordpress.org',
40+
'path' => '/afoo/',
41+
),
42+
'make.wordpress.org/' => array(
43+
'domain' => 'make.wordpress.org',
44+
'path' => '/',
45+
),
46+
'make.wordpress.org/foo/' => array(
47+
'domain' => 'make.wordpress.org',
48+
'path' => '/foo/',
49+
),
50+
'www.w.org/' => array(
51+
'domain' => 'www.w.org',
52+
'path' => '/',
53+
),
54+
'www.w.org/foo/' => array(
55+
'domain' => 'www.w.org',
56+
'path' => '/foo/',
57+
),
58+
'www.w.org/foo/bar/' => array(
59+
'domain' => 'www.w.org',
60+
'path' => '/foo/bar/',
61+
),
62+
'test.example.org/' => array(
63+
'domain' => 'test.example.org',
64+
'path' => '/',
65+
),
66+
'test2.example.org/' => array(
67+
'domain' => 'test2.example.org',
68+
'path' => '/',
69+
),
70+
'test3.example.org/zig/' => array(
71+
'domain' => 'test3.example.org',
72+
'path' => '/zig/',
73+
),
74+
'atest.example.org/' => array(
75+
'domain' => 'atest.example.org',
76+
'path' => '/',
77+
),
78+
);
79+
80+
foreach ( self::$site_ids as &$id ) {
81+
$id = $factory->blog->create( $id );
82+
}
83+
unset( $id );
84+
}
85+
86+
public static function wpTearDownAfterClass() {
87+
foreach ( self::$site_ids as $site_id ) {
88+
wp_delete_site( $site_id );
89+
}
90+
}
91+
92+
/**
93+
* @ticket 42066
94+
*
95+
* @covers WP_MS_Users_List_Table::get_views
96+
*/
97+
public function test_get_views_should_return_views_by_default() {
98+
$expected = array(
99+
'all' => '<a href="http://example.org/wp-admin/network/users.php" class="current" aria-current="page">All <span class="count">(1)</span></a>',
100+
'super' => '<a href="http://example.org/wp-admin/network/users.php?role=super">Super Admin <span class="count">(1)</span></a>',
101+
);
102+
103+
$this->assertSame( $expected, $this->table->get_views() );
104+
}
105+
}
106+
endif;

0 commit comments

Comments
 (0)