woocommerce-paypal-payments/modules.local/cache-module/tests/PHPUnit/Cache/TransientDeleteTest.php

40 lines
996 B
PHP
Raw Normal View History

2020-04-10 12:55:50 +03:00
<?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
{
2020-04-13 11:52:50 +03:00
public function testDelete()
{
2020-04-10 12:55:50 +03:00
$testee = new Transient('group');
expect('delete_transient')
->once()
->with('groupkey')
->andReturn(true);
$this->assertTrue($testee->delete('key'));
}
2020-04-13 11:52:50 +03:00
public function testDeleteFails()
{
2020-04-10 12:55:50 +03:00
$testee = new Transient('group');
expect('delete_transient')
->once()
->with('groupkey')
->andReturn(false);
$this->assertFalse($testee->delete('key'));
}
2020-04-13 11:52:50 +03:00
public function testDeleteThrowsErrorIfKeyIsNotAString()
{
2020-04-10 12:55:50 +03:00
$testee = new Transient('group');
$this->expectException(InvalidCacheArgumentException::class);
$testee->delete(123);
}
2020-04-13 11:52:50 +03:00
}