Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2021-04-20 23:03:52 +0300
committerGitHub <noreply@github.com>2021-04-20 23:03:52 +0300
commit9e8690d9127ab63caf66cd09d4d86647ae3ad6a7 (patch)
treec26481811c5e8cfdb9182311fe7fc3ea81b96961
parent5448306238eca2c2eba15004439d26b5ceaffe80 (diff)
parentc6978bac809a2a9336be9f3795ebe6bf2396a458 (diff)
Merge pull request #26654 from nextcloud/bugfix/noid/fix-security-credentials-manager-test
Fix security credentials manager test
-rw-r--r--tests/lib/Security/CredentialsManagerTest.php29
1 files changed, 11 insertions, 18 deletions
diff --git a/tests/lib/Security/CredentialsManagerTest.php b/tests/lib/Security/CredentialsManagerTest.php
index 3ce80227f44..ce3e82a410b 100644
--- a/tests/lib/Security/CredentialsManagerTest.php
+++ b/tests/lib/Security/CredentialsManagerTest.php
@@ -24,6 +24,9 @@ namespace Test\Security;
use OC\DB\ConnectionAdapter;
use OC\Security\CredentialsManager;
use OC\SystemConfig;
+use OCP\DB\IResult;
+use OCP\DB\QueryBuilder\IExpressionBuilder;
+use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\ILogger;
use OCP\Security\ICrypto;
@@ -39,9 +42,6 @@ class CredentialsManagerTest extends \Test\TestCase {
/** @var IDBConnection */
protected $dbConnection;
- /** @var ConnectionAdapter */
- protected $dbConnectionAdapter;
-
/** @var CredentialsManager */
protected $manager;
@@ -51,16 +51,11 @@ class CredentialsManagerTest extends \Test\TestCase {
$this->dbConnection = $this->getMockBuilder(IDBConnection::class)
->disableOriginalConstructor()
->getMock();
- $this->dbConnectionAdapter = $this->getMockBuilder(ConnectionAdapter::class)
- ->disableOriginalConstructor()
- ->getMock();
$this->manager = new CredentialsManager($this->crypto, $this->dbConnection);
}
private function getQueryResult($row) {
- $result = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement')
- ->disableOriginalConstructor()
- ->getMock();
+ $result = $this->createMock(IResult::class);
$result->expects($this->any())
->method('fetch')
@@ -98,19 +93,17 @@ class CredentialsManagerTest extends \Test\TestCase {
->with('baz')
->willReturn(json_encode('bar'));
- $qb = $this->getMockBuilder(\OC\DB\QueryBuilder\QueryBuilder::class)
- ->setConstructorArgs([
- $this->dbConnectionAdapter,
- $this->createMock(SystemConfig::class),
- $this->createMock(ILogger::class),
- ])
- ->setMethods(['execute'])
- ->getMock();
+ $eb = $this->createMock(IExpressionBuilder::class);
+ $qb = $this->createMock(IQueryBuilder::class);
+ $qb->method('select')->willReturnSelf();
+ $qb->method('from')->willReturnSelf();
+ $qb->method('where')->willReturnSelf();
+ $qb->method('expr')->willReturn($eb);
$qb->expects($this->once())
->method('execute')
->willReturn($this->getQueryResult(['credentials' => 'baz']));
- $this->dbConnectionAdapter->expects($this->once())
+ $this->dbConnection->expects($this->once())
->method('getQueryBuilder')
->willReturn($qb);