diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/DB/QueryBuilder/QueryBuilderTest.php | 24 | ||||
-rw-r--r-- | tests/lib/Security/CredentialsManagerTest.php | 12 |
2 files changed, 29 insertions, 7 deletions
diff --git a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php index 3c10d25c535..171b44fe92d 100644 --- a/tests/lib/DB/QueryBuilder/QueryBuilderTest.php +++ b/tests/lib/DB/QueryBuilder/QueryBuilderTest.php @@ -25,7 +25,9 @@ use Doctrine\DBAL\Query\Expression\CompositeExpression; use OC\DB\QueryBuilder\Literal; use OC\DB\QueryBuilder\Parameter; use OC\DB\QueryBuilder\QueryBuilder; +use OC\SystemConfig; use OCP\IDBConnection; +use OCP\ILogger; /** * Class QueryBuilderTest @@ -41,11 +43,19 @@ class QueryBuilderTest extends \Test\TestCase { /** @var IDBConnection */ protected $connection; + /** @var SystemConfig|\PHPUnit_Framework_MockObject_MockObject */ + protected $config; + + /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ + protected $logger; + protected function setUp() { parent::setUp(); $this->connection = \OC::$server->getDatabaseConnection(); - $this->queryBuilder = new QueryBuilder($this->connection); + $this->config = $this->createMock(SystemConfig::class); + $this->logger = $this->createMock(ILogger::class); + $this->queryBuilder = new QueryBuilder($this->connection, $this->config, $this->logger); } protected function createTestingRows($appId = 'testFirstResult') { @@ -166,7 +176,9 @@ class QueryBuilderTest extends \Test\TestCase { } public function dataSelect() { - $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection()); + $config = $this->createMock(SystemConfig::class); + $logger = $this->createMock(ILogger::class); + $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger); return [ // select('column1') [['configvalue'], ['configvalue' => '99']], @@ -232,7 +244,9 @@ class QueryBuilderTest extends \Test\TestCase { } public function dataSelectAlias() { - $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection()); + $config = $this->createMock(SystemConfig::class); + $logger = $this->createMock(ILogger::class); + $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger); return [ ['configvalue', 'cv', ['cv' => '99']], [$queryBuilder->expr()->literal('column1'), 'thing', ['thing' => 'column1']], @@ -301,7 +315,9 @@ class QueryBuilderTest extends \Test\TestCase { } public function dataAddSelect() { - $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection()); + $config = $this->createMock(SystemConfig::class); + $logger = $this->createMock(ILogger::class); + $queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger); return [ // addSelect('column1') [['configvalue'], ['appid' => 'testFirstResult', 'configvalue' => '99']], diff --git a/tests/lib/Security/CredentialsManagerTest.php b/tests/lib/Security/CredentialsManagerTest.php index cffcc02817c..38da26a21a9 100644 --- a/tests/lib/Security/CredentialsManagerTest.php +++ b/tests/lib/Security/CredentialsManagerTest.php @@ -21,6 +21,8 @@ namespace Test\Security; +use OC\SystemConfig; +use OCP\ILogger; use \OCP\Security\ICrypto; use \OCP\IDBConnection; use \OC\Security\CredentialsManager; @@ -45,7 +47,7 @@ class CredentialsManagerTest extends \Test\TestCase { $this->manager = new CredentialsManager($this->crypto, $this->dbConnection); } - private function getQeuryResult($row) { + private function getQueryResult($row) { $result = $this->getMockBuilder('\Doctrine\DBAL\Driver\Statement') ->disableOriginalConstructor() ->getMock(); @@ -87,12 +89,16 @@ class CredentialsManagerTest extends \Test\TestCase { ->willReturn(json_encode('bar')); $qb = $this->getMockBuilder('\OC\DB\QueryBuilder\QueryBuilder') - ->setConstructorArgs([$this->dbConnection]) + ->setConstructorArgs([ + $this->dbConnection, + $this->createMock(SystemConfig::class), + $this->createMock(ILogger::class), + ]) ->setMethods(['execute']) ->getMock(); $qb->expects($this->once()) ->method('execute') - ->willReturn($this->getQeuryResult(['credentials' => 'baz'])); + ->willReturn($this->getQueryResult(['credentials' => 'baz'])); $this->dbConnection->expects($this->once()) ->method('getQueryBuilder') |