summaryrefslogtreecommitdiffstats
path: root/tests/unit/db
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/db')
-rw-r--r--tests/unit/db/FeedMapperTest.php2
-rw-r--r--tests/unit/db/FolderMapperTest.php2
-rw-r--r--tests/unit/db/ItemMapperTest.php2
-rw-r--r--tests/unit/db/MapperFactoryTest.php19
-rw-r--r--tests/unit/db/MapperTest.php18
-rw-r--r--tests/unit/db/postgres/ItemMapperTest.php2
6 files changed, 27 insertions, 18 deletions
diff --git a/tests/unit/db/FeedMapperTest.php b/tests/unit/db/FeedMapperTest.php
index c424e57e7..4e78dbf3a 100644
--- a/tests/unit/db/FeedMapperTest.php
+++ b/tests/unit/db/FeedMapperTest.php
@@ -36,7 +36,7 @@ class FeedMapperTest extends \OCA\News\Utility\MapperTestUtility {
protected function setUp(){
$this->beforeEach();
- $this->mapper = new FeedMapper($this->api);
+ $this->mapper = new FeedMapper($this->db);
// create mock feeds
$feed1 = new Feed();
diff --git a/tests/unit/db/FolderMapperTest.php b/tests/unit/db/FolderMapperTest.php
index b27cf80ab..9254bf493 100644
--- a/tests/unit/db/FolderMapperTest.php
+++ b/tests/unit/db/FolderMapperTest.php
@@ -37,7 +37,7 @@ class FolderMapperTest extends \OCA\News\Utility\MapperTestUtility {
protected function setUp(){
$this->beforeEach();
- $this->folderMapper = new FolderMapper($this->api);
+ $this->folderMapper = new FolderMapper($this->db);
// create mock folders
$folder1 = new Folder();
diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php
index fbb77ea12..bf8210f5f 100644
--- a/tests/unit/db/ItemMapperTest.php
+++ b/tests/unit/db/ItemMapperTest.php
@@ -44,7 +44,7 @@ class ItemMapperTest extends \OCA\News\Utility\MapperTestUtility {
{
$this->beforeEach();
- $this->mapper = new ItemMapper($this->api);
+ $this->mapper = new ItemMapper($this->db);
// create mock items
$item1 = new Item();
diff --git a/tests/unit/db/MapperFactoryTest.php b/tests/unit/db/MapperFactoryTest.php
index 51e70f526..5f07f7cbb 100644
--- a/tests/unit/db/MapperFactoryTest.php
+++ b/tests/unit/db/MapperFactoryTest.php
@@ -31,42 +31,47 @@ require_once(__DIR__ . "/../../classloader.php");
class MapperFactoryTest extends \PHPUnit_Framework_TestCase {
+ private $db;
+ private $settings;
public function setUp() {
- $this->api = $this->getMockBuilder('\OCA\News\Core\API')
+ $this->settings = $this->getMockBuilder('\OCA\News\Core\Settings')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->db = $this->getMockBuilder('\OCA\News\Core\Db')
->disableOriginalConstructor()
->getMock();
}
public function testGetItemMapperSqlite() {
- $this->api->expects($this->once())
+ $this->settings->expects($this->once())
->method('getSystemValue')
->with($this->equalTo('dbtype'))
->will($this->returnValue('sqlite'));
- $factory = new MapperFactory($this->api);
+ $factory = new MapperFactory($this->settings, $this->db);
$this->assertTrue($factory->getItemMapper() instanceof ItemMapper);
}
public function testGetItemMapperMysql() {
- $this->api->expects($this->once())
+ $this->settings->expects($this->once())
->method('getSystemValue')
->with($this->equalTo('dbtype'))
->will($this->returnValue('mysql'));
- $factory = new MapperFactory($this->api);
+ $factory = new MapperFactory($this->settings, $this->db);
$this->assertTrue($factory->getItemMapper() instanceof ItemMapper);
}
public function testGetItemMapperPostgres() {
- $this->api->expects($this->once())
+ $this->settings->expects($this->once())
->method('getSystemValue')
->with($this->equalTo('dbtype'))
->will($this->returnValue('pgsql'));
- $factory = new MapperFactory($this->api);
+ $factory = new MapperFactory($this->settings, $this->db);
$this->assertTrue($factory->getItemMapper() instanceof \OCA\News\Db\Postgres\ItemMapper);
}
diff --git a/tests/unit/db/MapperTest.php b/tests/unit/db/MapperTest.php
index 3e483d764..1f41c2ba0 100644
--- a/tests/unit/db/MapperTest.php
+++ b/tests/unit/db/MapperTest.php
@@ -24,7 +24,7 @@
namespace OCA\News\Db;
-use OCA\News\Core\API;
+use OCA\News\Core\Db;
use OCA\News\Utility\MapperTestUtility;
@@ -38,7 +38,7 @@ class Example extends Entity {
class ExampleMapper extends Mapper {
- public function __construct(API $api){ parent::__construct($api, 'table'); }
+ public function __construct(Db $db){ parent::__construct($db, 'table'); }
public function find($table, $id){ return $this->findOneQuery($table, $id); }
public function findOneEntity($table, $id){ return $this->findEntity($table, $id); }
public function findAll($table){ return $this->findAllQuery($table); }
@@ -54,7 +54,11 @@ class MapperTest extends MapperTestUtility {
public function setUp(){
$this->beforeEach();
- $this->mapper = new ExampleMapper($this->api);
+ $this->db = $this->getMockBuilder(
+ '\OCA\News\Core\Db')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->mapper = new ExampleMapper($this->db);
}
@@ -141,11 +145,11 @@ class MapperTest extends MapperTestUtility {
public function testCreate(){
- $this->api->expects($this->once())
+ $this->db->expects($this->once())
->method('getInsertId')
->with($this->equalTo('*PREFIX*table'))
->will($this->returnValue(3));
- $this->mapper = new ExampleMapper($this->api);
+ $this->mapper = new ExampleMapper($this->db);
$sql = 'INSERT INTO `*PREFIX*table`(`pre_name`,`email`) ' .
'VALUES(?,?)';
@@ -161,11 +165,11 @@ class MapperTest extends MapperTestUtility {
public function testCreateShouldReturnItemWithCorrectInsertId(){
- $this->api->expects($this->once())
+ $this->db->expects($this->once())
->method('getInsertId')
->with($this->equalTo('*PREFIX*table'))
->will($this->returnValue(3));
- $this->mapper = new ExampleMapper($this->api);
+ $this->mapper = new ExampleMapper($this->db);
$sql = 'INSERT INTO `*PREFIX*table`(`pre_name`,`email`) ' .
'VALUES(?,?)';
diff --git a/tests/unit/db/postgres/ItemMapperTest.php b/tests/unit/db/postgres/ItemMapperTest.php
index ff8651233..2fbd7a71a 100644
--- a/tests/unit/db/postgres/ItemMapperTest.php
+++ b/tests/unit/db/postgres/ItemMapperTest.php
@@ -48,7 +48,7 @@ class ItemMapperTest extends \OCA\News\Utility\MapperTestUtility {
{
$this->beforeEach();
- $this->mapper = new ItemMapper($this->api);
+ $this->mapper = new ItemMapper($this->db);
// create mock items
$item1 = new Item();