Files
Côme Chilliet e18cb7c3c1 fix(tests): Improve cache automocks and simplify a bit getting an automock
getAutoMock can now be used and you do not care whether it was already
 created or not yet. Same for getCacheAutoMock.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2026-09-28 15:57:43 +02:00

43 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Http\Client;
use OC\Http\Client\NegativeDnsCache;
class NegativeDnsCacheTest extends \Test\TestCase {
private NegativeDnsCache $negativeDnsCache;
#[\Override]
protected function setUp(): void {
parent::setUp();
$this->negativeDnsCache = $this->createInstanceWithMocks(NegativeDnsCache::class);
}
public function testSetNegativeCacheForDnsType() : void {
$this->getCacheAutoMock('NegativeDnsCache')
->expects($this->once())
->method('set')
->with('www.example.com-1', 'true', 3600);
$this->negativeDnsCache->setNegativeCacheForDnsType('www.example.com', DNS_A, 3600);
}
public function testIsNegativeCached(): void {
$this->getCacheAutoMock('NegativeDnsCache')
->expects($this->once())
->method('hasKey')
->with('www.example.com-1')
->willReturn(true);
$this->assertTrue($this->negativeDnsCache->isNegativeCached('www.example.com', DNS_A));
}
}