woocommerce-paypal-payments/modules.local/cache-module/tests/PHPUnit/Cache/TransientDeleteTest.php
2020-04-13 11:52:50 +03:00

39 lines
996 B
PHP

<?php
declare(strict_types=1);
namespace Inpsyde\CacheModule\Cache;
use Inpsyde\CacheModule\Exception\InvalidCacheArgumentException;
use PHPUnit\Framework\TestCase;
use function Brain\Monkey\Functions\expect;
class TransientDeleteTest extends TestCase
{
public function testDelete()
{
$testee = new Transient('group');
expect('delete_transient')
->once()
->with('groupkey')
->andReturn(true);
$this->assertTrue($testee->delete('key'));
}
public function testDeleteFails()
{
$testee = new Transient('group');
expect('delete_transient')
->once()
->with('groupkey')
->andReturn(false);
$this->assertFalse($testee->delete('key'));
}
public function testDeleteThrowsErrorIfKeyIsNotAString()
{
$testee = new Transient('group');
$this->expectException(InvalidCacheArgumentException::class);
$testee->delete(123);
}
}