Skip to content

Commit 3e61a6c

Browse files
committed
Add the unit test to verify the cache is deleted once delete_plugin is called
1 parent 60e7d09 commit 3e61a6c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/phpunit/tests/ajax/wpAjaxDeletePlugin.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function test_invalid_file() {
131131
* @group ms-excluded
132132
*
133133
* @covers ::delete_plugins
134+
* @covers ::wp_clean_plugins_cache
134135
*/
135136
public function test_delete_plugin() {
136137
$this->_setRole( 'administrator' );
@@ -139,6 +140,17 @@ public function test_delete_plugin() {
139140
$_POST['plugin'] = 'foo.php';
140141
$_POST['slug'] = 'foo';
141142

143+
// Adds the plugin cache.
144+
$plugins_cache = array(
145+
'' => array(
146+
'foo.php' => array(
147+
'Name' => 'Foo Plugin',
148+
'Version' => '1.0',
149+
),
150+
),
151+
);
152+
wp_cache_set( 'plugins', $plugins_cache, 'plugins' );
153+
142154
// Make the request.
143155
try {
144156
$this->_handleAjax( 'delete-plugin' );
@@ -160,5 +172,8 @@ public function test_delete_plugin() {
160172
);
161173

162174
$this->assertSameSets( $expected, $response );
175+
176+
// Verify that wp_clean_plugins_cache() was called and cleared both cache and transient.
177+
$this->assertFalse( wp_cache_get( 'plugins', 'plugins' ), 'Plugins cache should be cleared after delete_plugins()' );
163178
}
164179
}

0 commit comments

Comments
 (0)