Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions tests/phpunit/tests/general/deleteGetCalendarCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/**
* Tests for the `delete_get_calendar_cache()` function.
*
* @group general
*
* @covers ::delete_get_calendar_cache
*/
class Tests_General_DeleteGetCalendarCache extends WP_UnitTestCase {

/**
* Tests that delete_get_calendar_cache() clears the calendar cache.
*
* @ticket 65819
*/
public function test_delete_get_calendar_cache_clears_cache() {
wp_cache_set( 'get_calendar', array( 'sample_key' => 'calendar_content' ), 'calendar' );
$this->assertSame(
array( 'sample_key' => 'calendar_content' ),
wp_cache_get( 'get_calendar', 'calendar' )
);

delete_get_calendar_cache();

$this->assertFalse( wp_cache_get( 'get_calendar', 'calendar' ) );
}

/**
* Tests that delete_get_calendar_cache() executes without error when cache does not exist.
*
* @ticket 65819
*/
public function test_delete_get_calendar_cache_when_empty() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: this test still passes if delete_get_calendar_cache() is empty, since the setup already leaves the cache clear. Feel free to drop it and keep the first test, which does fail in that case.

wp_cache_delete( 'get_calendar', 'calendar' );

delete_get_calendar_cache();

$this->assertFalse( wp_cache_get( 'get_calendar', 'calendar' ) );
}
}
Loading