|
| 1 | +<?php |
| 2 | + |
| 3 | +if ( is_multisite() ) : |
| 4 | + |
| 5 | + /** |
| 6 | + * @group admin |
| 7 | + * @group network-admin |
| 8 | + * |
| 9 | + * @covers WP_MS_Themes_List_Table |
| 10 | + */ |
| 11 | + class Tests_Multisite_wpMsThemesListTable extends WP_UnitTestCase { |
| 12 | + protected static $site_ids; |
| 13 | + |
| 14 | + /** |
| 15 | + * @var WP_MS_Themes_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_Themes_List_Table', array( 'screen' => 'ms-themes' ) ); |
| 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_Themes_List_Table::get_views |
| 96 | + */ |
| 97 | + public function test_get_views_should_return_views_by_default() { |
| 98 | + global $totals; |
| 99 | + |
| 100 | + $totals_backup = $totals; |
| 101 | + $totals = array( |
| 102 | + 'all' => 21, |
| 103 | + 'enabled' => 1, |
| 104 | + 'disabled' => 2, |
| 105 | + 'upgrade' => 3, |
| 106 | + 'broken' => 4, |
| 107 | + 'auto-update-enabled' => 5, |
| 108 | + 'auto-update-disabled' => 6, |
| 109 | + ); |
| 110 | + |
| 111 | + $expected = array( |
| 112 | + 'all' => '<a href=\'themes.php?theme_status=all\' class="current" aria-current="page">All <span class="count">(21)</span></a>', |
| 113 | + 'enabled' => '<a href=\'themes.php?theme_status=enabled\'>Enabled <span class="count">(1)</span></a>', |
| 114 | + 'disabled' => '<a href=\'themes.php?theme_status=disabled\'>Disabled <span class="count">(2)</span></a>', |
| 115 | + 'upgrade' => '<a href=\'themes.php?theme_status=upgrade\'>Update Available <span class="count">(3)</span></a>', |
| 116 | + 'broken' => '<a href=\'themes.php?theme_status=broken\'>Broken <span class="count">(4)</span></a>', |
| 117 | + 'auto-update-enabled' => '<a href=\'themes.php?theme_status=auto-update-enabled\'>Auto-updates Enabled <span class="count">(5)</span></a>', |
| 118 | + 'auto-update-disabled' => '<a href=\'themes.php?theme_status=auto-update-disabled\'>Auto-updates Disabled <span class="count">(6)</span></a>', |
| 119 | + ); |
| 120 | + |
| 121 | + $actual = $this->table->get_views(); |
| 122 | + $totals = $totals_backup; |
| 123 | + |
| 124 | + $this->assertSame( $expected, $actual ); |
| 125 | + } |
| 126 | + } |
| 127 | +endif; |
0 commit comments