Adjust test

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
Lukas Reschke 2021-03-30 19:50:11 +00:00 committed by GitHub
parent 5f3abffe6f
commit 9dab851931
1 changed files with 14 additions and 7 deletions

View File

@ -26,6 +26,7 @@ declare(strict_types=1);
namespace Test\Http\Client;
use OC\Http\Client\NegativeDnsCache;
use OCP\ICache;
use OCP\ICacheFactory;
@ -42,7 +43,7 @@ class NegativeDnsCacheTest extends \Test\TestCase {
$this->cache = $this->createMock(ICache::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->cacheFactory->expects($this->at(0))
$this->cacheFactory
->method('createLocal')
->with('NegativeDnsCache')
->willReturn($this->cache);
@ -51,15 +52,21 @@ class NegativeDnsCacheTest extends \Test\TestCase {
}
public function testSetNegativeCacheForDnsType() : void {
$this->cache->set($this->createCacheKey($domain, $type), "true", $ttl);
$this->cache
->expects($this->once())
->method('set')
->with('www.example.com-1', 'true', 3600);
$this->negativeDnsCache->setNegativeCacheForDnsType("www.example.com", DNS_A, 3600);
}
public function testIsNegativeCached() {
$this->cache->expects($this->at(0))
->method('createDistributed')
->with('hasKey', 'www.example.com-0')
->willReturn($imagePathCache);
$this->cache
->expects($this->once())
->method('hasKey')
->with('www.example.com-1')
->willReturn(true);
$this->negativeDnsCache->hasKey('www.example.com', DNS_A);
$this->assertTrue($this->negativeDnsCache->isNegativeCached("www.example.com", DNS_A));
}
}