|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Test module related methods in Jetpack and Jetpack_Admin class. |
| 3 | + * Test module discovery, administration, and list-table filtering. |
4 | 4 | * |
5 | 5 | * @package jetpack |
6 | 6 | */ |
|
9 | 9 | use PHPUnit\Framework\Attributes\CoversClass; |
10 | 10 | use PHPUnit\Framework\Attributes\DataProvider; |
11 | 11 |
|
| 12 | +require_once JETPACK__PLUGIN_DIR . 'class.jetpack-modules-list-table.php'; |
| 13 | + |
12 | 14 | /** |
13 | | - * Test module related methods in Jetpack and Jetpack_Admin class. |
| 15 | + * Test module discovery, administration, and list-table filtering. |
14 | 16 | * |
15 | 17 | * @covers \Jetpack_Admin |
| 18 | + * @covers \Jetpack_Modules_List_Table |
16 | 19 | */ |
17 | 20 | #[CoversClass( Jetpack_Admin::class )] |
| 21 | +#[CoversClass( Jetpack_Modules_List_Table::class )] |
18 | 22 | class Get_Modules_Test extends WP_UnitTestCase { |
19 | 23 | use \Automattic\Jetpack\PHPUnit\WP_UnitTestCase_Fix; |
20 | 24 |
|
@@ -255,4 +259,36 @@ public function test_get_module_valid_module() { |
255 | 259 | public function test_get_module_module_no_info() { |
256 | 260 | $this->assertFalse( Jetpack::get_module( 'module-extras' ) ); |
257 | 261 | } |
| 262 | + |
| 263 | + /** |
| 264 | + * Ignore an array tag in the view selector. |
| 265 | + */ |
| 266 | + public function test_array_module_tag_selects_all_view() { |
| 267 | + $original_get = $_GET; |
| 268 | + try { |
| 269 | + $_GET['module_tag'] = array( 'x' ); |
| 270 | + $table = $this->getMockBuilder( Jetpack_Modules_List_Table::class ) |
| 271 | + ->disableOriginalConstructor() |
| 272 | + ->onlyMethods( array( 'get_views' ) ) |
| 273 | + ->getMock(); |
| 274 | + $table->expects( $this->once() )->method( 'get_views' )->willReturn( array( 'all' => 'All' ) ); |
| 275 | + $this->expectOutputRegex( "/\A<ul class='subsubsub'>\s*<li class='all current'>All<\/li>\s*<\/ul>\z/" ); |
| 276 | + $table->views(); |
| 277 | + } finally { |
| 278 | + $_GET = $original_get; |
| 279 | + } |
| 280 | + } |
| 281 | + |
| 282 | + /** |
| 283 | + * Ignore an array tag in the module filter. |
| 284 | + */ |
| 285 | + public function test_array_module_tag_does_not_filter_modules() { |
| 286 | + $original_request = $_REQUEST; |
| 287 | + try { |
| 288 | + $_REQUEST['module_tag'] = array( 'x' ); |
| 289 | + $this->assertTrue( Jetpack_Modules_List_Table::is_module_displayed( array( 'module_tags' => array( 'Social' ) ) ) ); |
| 290 | + } finally { |
| 291 | + $_REQUEST = $original_request; |
| 292 | + } |
| 293 | + } |
258 | 294 | } |
0 commit comments