Fix unit tests

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2022-01-31 20:36:06 +01:00
parent 83c1d1ef3a
commit ad55d3b4c0
No known key found for this signature in database
GPG key ID: 7076EA9751AACDDA
2 changed files with 10 additions and 2 deletions

View file

@ -25,6 +25,7 @@ namespace Test\Authentication\Token;
use OC\Authentication\Token\DefaultTokenCleanupJob;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\Manager;
use OCP\IConfig;
use Test\TestCase;
class DefaultTokenCleanupJobTest extends TestCase {
@ -36,11 +37,13 @@ class DefaultTokenCleanupJobTest extends TestCase {
protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->tokenProvider = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()
->getMock();
$this->overwriteService(IProvider::class, $this->tokenProvider);
$this->job = new DefaultTokenCleanupJob();
$this->job = new DefaultTokenCleanupJob($this->config);
}
public function testRun() {

View file

@ -27,8 +27,10 @@ use OC\Authentication\Token\DefaultToken;
use OC\Authentication\Token\DefaultTokenMapper;
use OC\Authentication\Token\IToken;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IUser;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
/**
@ -44,6 +46,8 @@ class DefaultTokenMapperTest extends TestCase {
/** @var IDBConnection */
private $dbConnection;
/** @var IConfig|MockObject */
private $config;
private $time;
protected function setUp(): void {
@ -51,9 +55,10 @@ class DefaultTokenMapperTest extends TestCase {
$this->dbConnection = OC::$server->getDatabaseConnection();
$this->time = time();
$this->config = $this->createMock(IConfig::class);
$this->resetDatabase();
$this->mapper = new DefaultTokenMapper($this->dbConnection);
$this->mapper = new DefaultTokenMapper($this->dbConnection, $this->config);
}
private function resetDatabase() {