fixing errors

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
Maxence Lange 2021-03-23 11:20:08 -01:00
parent ae81067734
commit b31e7bbafe
2 changed files with 14 additions and 8 deletions

View File

@ -24,11 +24,11 @@ namespace Test\DB\QueryBuilder;
use Doctrine\DBAL\Query\Expression\CompositeExpression; use Doctrine\DBAL\Query\Expression\CompositeExpression;
use Doctrine\DBAL\Query\QueryException; use Doctrine\DBAL\Query\QueryException;
use Doctrine\DBAL\Result; use Doctrine\DBAL\Result;
use OC\DB\ConnectionAdapter;
use OC\DB\QueryBuilder\Literal; use OC\DB\QueryBuilder\Literal;
use OC\DB\QueryBuilder\Parameter; use OC\DB\QueryBuilder\Parameter;
use OC\DB\QueryBuilder\QueryBuilder; use OC\DB\QueryBuilder\QueryBuilder;
use OC\SystemConfig; use OC\SystemConfig;
use OCP\IDBConnection;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
/** /**
@ -42,7 +42,7 @@ class QueryBuilderTest extends \Test\TestCase {
/** @var QueryBuilder */ /** @var QueryBuilder */
protected $queryBuilder; protected $queryBuilder;
/** @var IDBConnection */ /** @var ConnectionAdapter */
protected $connection; protected $connection;
/** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */ /** @var SystemConfig|\PHPUnit\Framework\MockObject\MockObject */
@ -54,7 +54,7 @@ class QueryBuilderTest extends \Test\TestCase {
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection(); $this->connection = \OC::$server->get(ConnectionAdapter::class);
$this->config = $this->createMock(SystemConfig::class); $this->config = $this->createMock(SystemConfig::class);
$this->logger = $this->createMock(LoggerInterface::class); $this->logger = $this->createMock(LoggerInterface::class);
$this->queryBuilder = new QueryBuilder($this->connection, $this->config, $this->logger); $this->queryBuilder = new QueryBuilder($this->connection, $this->config, $this->logger);
@ -178,7 +178,9 @@ class QueryBuilderTest extends \Test\TestCase {
} }
public function dataSelect() { public function dataSelect() {
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $this->config, $this->logger); $config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(LoggerInterface::class);
$queryBuilder = new QueryBuilder(\OC::$server->get(ConnectionAdapter::class), $config, $logger);
return [ return [
// select('column1') // select('column1')
[['configvalue'], ['configvalue' => '99']], [['configvalue'], ['configvalue' => '99']],
@ -244,7 +246,9 @@ class QueryBuilderTest extends \Test\TestCase {
} }
public function dataSelectAlias() { public function dataSelectAlias() {
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $this->config, $this->logger); $config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(LoggerInterface::class);
$queryBuilder = new QueryBuilder(\OC::$server->get(ConnectionAdapter::class), $config, $logger);
return [ return [
['configvalue', 'cv', ['cv' => '99']], ['configvalue', 'cv', ['cv' => '99']],
[$queryBuilder->expr()->literal('column1'), 'thing', ['thing' => 'column1']], [$queryBuilder->expr()->literal('column1'), 'thing', ['thing' => 'column1']],
@ -351,7 +355,9 @@ class QueryBuilderTest extends \Test\TestCase {
} }
public function dataAddSelect() { public function dataAddSelect() {
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $this->config, $this->logger); $config = $this->createMock(SystemConfig::class);
$logger = $this->createMock(LoggerInterface::class);
$queryBuilder = new QueryBuilder(\OC::$server->get(ConnectionAdapter::class), $config, $logger);
return [ return [
// addSelect('column1') // addSelect('column1')
[['configvalue'], ['appid' => 'testFirstResult', 'configvalue' => '99']], [['configvalue'], ['appid' => 'testFirstResult', 'configvalue' => '99']],

View File

@ -25,8 +25,8 @@ use OC\DB\ConnectionAdapter;
use OC\Security\CredentialsManager; use OC\Security\CredentialsManager;
use OC\SystemConfig; use OC\SystemConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\ILogger;
use OCP\Security\ICrypto; use OCP\Security\ICrypto;
use Psr\Log\LoggerInterface;
/** /**
* @group DB * @group DB
@ -102,7 +102,7 @@ class CredentialsManagerTest extends \Test\TestCase {
->setConstructorArgs([ ->setConstructorArgs([
$this->dbConnectionAdapter, $this->dbConnectionAdapter,
$this->createMock(SystemConfig::class), $this->createMock(SystemConfig::class),
$this->createMock(ILogger::class), $this->createMock(LoggerInterface::class),
]) ])
->setMethods(['execute']) ->setMethods(['execute'])
->getMock(); ->getMock();