| | 99 | |
| | 100 | /** |
| | 101 | * @covers ::get_plugin_files |
| | 102 | */ |
| | 103 | function test_get_plugin_files_single() { |
| | 104 | $name = 'hello.php'; |
| | 105 | $this->assertEquals( array( $name ), get_plugin_files( $name ) ); |
| | 106 | } |
| | 107 | |
| | 108 | /** |
| | 109 | * @covers ::get_mu_plugins |
| | 110 | */ |
| | 111 | function test_get_mu_plugins_empty() { |
| | 112 | $this->assertEquals( array(), get_mu_plugins() ); |
| | 113 | } |
| | 114 | |
| | 115 | /** |
| | 116 | * @covers ::_sort_uname_callback |
| | 117 | */ |
| | 118 | function test_sort_uname_callback() { |
| | 119 | $this->assertLessThan( 0, _sort_uname_callback( array( 'Name' => 'a' ), array( 'Name' => 'b' ) ) ); |
| | 120 | $this->assertGreaterThan( 0, _sort_uname_callback( array( 'Name' => 'c' ), array( 'Name' => 'b' ) ) ); |
| | 121 | $this->assertEquals( 0, _sort_uname_callback( array( 'Name' => 'a' ), array( 'Name' => 'a' ) ) ); |
| | 122 | } |
| | 123 | |
| | 124 | /** |
| | 125 | * @covers ::get_dropins |
| | 126 | */ |
| | 127 | function test_get_dropins_empty() { |
| | 128 | $this->assertEquals( array(), get_dropins() ); |
| | 129 | } |
| | 130 | |
| | 131 | /** |
| | 132 | * @covers ::_get_dropins |
| | 133 | */ |
| | 134 | function test_get_dropins_not_empty() { |
| | 135 | $this->assertGreaterThan( 0, get_dropins() ); |
| | 136 | } |
| | 137 | |
| | 138 | /** |
| | 139 | * @covers ::is_network_only_plugin |
| | 140 | */ |
| | 141 | function test_is_network_only_plugin_hello() { |
| | 142 | $this->assertFalse( is_network_only_plugin( 'hello.php' ) ); |
| | 143 | } |
| | 144 | |
| | 145 | /** |
| | 146 | * @covers ::activate_plugins |
| | 147 | */ |
| | 148 | function test_activate_plugins_single_no_array() { |
| | 149 | $name = 'hello.php'; |
| | 150 | activate_plugins( $name ); |
| | 151 | $this->assertTrue( is_plugin_active( $name ) ); |
| | 152 | deactivate_plugins( $name ); |
| | 153 | } |
| | 154 | |
| | 155 | /** |
| | 156 | * @covers ::activate_plugins |
| | 157 | */ |
| | 158 | function test_activate_plugins_single_array() { |
| | 159 | $name = 'hello.php'; |
| | 160 | activate_plugins( array( $name ) ); |
| | 161 | $this->assertTrue( is_plugin_active( $name ) ); |
| | 162 | deactivate_plugins( $name ); |
| | 163 | } |
| | 164 | |
| | 165 | /** |
| | 166 | * @covers ::validate_active_plugins |
| | 167 | */ |
| | 168 | function test_validate_active_plugins_empty() { |
| | 169 | $this->assertEquals( array(), validate_active_plugins() ); |
| | 170 | } |
| | 171 | |
| | 172 | /** |
| | 173 | * @covers ::validate_active_plugins |
| | 174 | */ |
| | 175 | function test_validate_active_plugins_remove_invalid() { |
| | 176 | $plugin = $this->_create_plugin(); |
| | 177 | |
| | 178 | activate_plugin( $plugin[ 0 ] ); |
| | 179 | unlink( $plugin[ 1 ] ); |
| | 180 | |
| | 181 | $result = validate_active_plugins(); |
| | 182 | $this->assertTrue( isset( $result[ $plugin[ 0 ] ] ) ); |
| | 183 | } |
| | 184 | |
| | 185 | /** |
| | 186 | * @covers ::is_uninstallable_plugin |
| | 187 | */ |
| | 188 | function test_is_uninstallable_plugin() { |
| | 189 | $this->assertFalse( is_uninstallable_plugin( 'hello' ) ); |
| | 190 | } |
| | 191 | |
| | 192 | /** |
| | 193 | * @covers ::is_uninstallable_plugin |
| | 194 | */ |
| | 195 | function test_is_uninstallable_plugin_true() { |
| | 196 | $plugin = $this->_create_plugin(); |
| | 197 | |
| | 198 | $uninstallable_plugins = (array) get_option( 'uninstall_plugins' ); |
| | 199 | $uninstallable_plugins[ $plugin[ 0 ] ] = TRUE; |
| | 200 | update_option( 'uninstall_plugins', $uninstallable_plugins ); |
| | 201 | |
| | 202 | $this->assertTrue( is_uninstallable_plugin( $plugin[ 0 ] ) ); |
| | 203 | |
| | 204 | unset( $uninstallable_plugins[ $plugin[ 0 ] ] ); |
| | 205 | update_option( 'uninstall_plugins', $uninstallable_plugins ); |
| | 206 | |
| | 207 | unlink( $plugin[ 1 ] ); |
| | 208 | } |
| | 209 | |