summaryrefslogtreecommitdiffstats
path: root/tests/Unit/Db
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Unit/Db')
-rw-r--r--tests/Unit/Db/FeedMapperTest.php11
-rw-r--r--tests/Unit/Db/MapperTestUtility.php8
-rw-r--r--tests/Unit/Db/NewsMapperTest.php17
3 files changed, 22 insertions, 14 deletions
diff --git a/tests/Unit/Db/FeedMapperTest.php b/tests/Unit/Db/FeedMapperTest.php
index a6a4be866..c14b8995f 100644
--- a/tests/Unit/Db/FeedMapperTest.php
+++ b/tests/Unit/Db/FeedMapperTest.php
@@ -15,17 +15,17 @@ namespace OCA\News\Tests\Unit\Db;
use OCA\News\Db\Feed;
use OCA\News\Db\FeedMapperV2;
-use OCA\News\Db\Folder;
use OCA\News\Utility\Time;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\DB\QueryBuilder\IFunctionBuilder;
+use OCP\DB\QueryBuilder\IQueryFunction;
class FeedMapperTest extends MapperTestUtility
{
/** @var FeedMapperV2 */
private $class;
- /** @var Feeds[] */
+ /** @var Feed[] */
private $feeds;
/**
@@ -68,10 +68,13 @@ class FeedMapperTest extends MapperTestUtility
$funcbuilder = $this->getMockBuilder(IFunctionBuilder::class)
->getMock();
+ $func = $this->getMockBuilder(IQueryFunction::class)
+ ->getMock();
+
$funcbuilder->expects($this->once())
->method('count')
->with('items.id', 'unreadCount')
- ->will($this->returnValue('COUNT_FUNC'));
+ ->will($this->returnValue($func));
$this->builder->expects($this->once())
->method('func')
@@ -79,7 +82,7 @@ class FeedMapperTest extends MapperTestUtility
$this->builder->expects($this->once())
->method('select')
- ->with('feeds.*', 'COUNT_FUNC')
+ ->with('feeds.*', $func)
->will($this->returnSelf());
$this->builder->expects($this->once())
diff --git a/tests/Unit/Db/MapperTestUtility.php b/tests/Unit/Db/MapperTestUtility.php
index 725f0c3c0..3aa1d8aed 100644
--- a/tests/Unit/Db/MapperTestUtility.php
+++ b/tests/Unit/Db/MapperTestUtility.php
@@ -23,12 +23,11 @@
namespace OCA\News\Tests\Unit\Db;
-use Doctrine\DBAL\Driver\PDOStatement;
use Doctrine\DBAL\Driver\Statement;
-use OCA\News\Tests\Unit\Service\ServiceTest;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
+use PDOStatement;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
@@ -71,13 +70,14 @@ abstract class MapperTestUtility extends TestCase
->disableOriginalConstructor()
->getMock();
- $this->query = $this->getMockBuilder(\PDOStatement::class)
+ $this->query = $this->getMockBuilder(PDOStatement::class)
->getMock();
$this->builder = $this->getMockBuilder(IQueryBuilder::class)
->getMock();
$this->cursor = $this->getMockBuilder(Statement::class)
- ->getMock();
+ ->addMethods(['fetch', 'closeCursor'])
+ ->getMockForAbstractClass();
}
}
diff --git a/tests/Unit/Db/NewsMapperTest.php b/tests/Unit/Db/NewsMapperTest.php
index 5d75f740f..c7ce7342a 100644
--- a/tests/Unit/Db/NewsMapperTest.php
+++ b/tests/Unit/Db/NewsMapperTest.php
@@ -14,21 +14,26 @@
namespace OCA\News\Tests\Unit\Db;
use OCA\News\Db\Feed;
-use OCA\News\Db\FeedMapperV2;
-use OCA\News\Db\Folder;
use OCA\News\Db\NewsMapperV2;
use OCA\News\Utility\Time;
-use OCP\AppFramework\Db\DoesNotExistException;
-use OCP\AppFramework\Db\MultipleObjectsReturnedException;
-use OCP\DB\QueryBuilder\IFunctionBuilder;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
-use Test\TestCase;
+use PHPUnit\Framework\TestCase;
+/**
+ * Class TmpNewsMapper
+ *
+ * @package OCA\News\Tests\Unit\Db
+ */
abstract class TmpNewsMapper extends NewsMapperV2 {
const TABLE_NAME = 'NAME';
}
+/**
+ * Class NewsMapperTest
+ *
+ * @package OCA\News\Tests\Unit\Db
+ */
class NewsMapperTest extends TestCase
{
/** @var IDBConnection */