summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-05-21 21:10:45 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-05-21 21:10:45 +0200
commit031ba0ce524f35c70b776173917ae4ce3819951e (patch)
treea54c45c0e9b9412ae7970034e7621115dce714c8 /tests
parent284d428111d03c16561c15dc98daaab802d2cac4 (diff)
When creating a feed or folder the it should purge the deleted
Edit fix #176
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/businesslayer/FeedBusinessLayerTest.php20
-rw-r--r--tests/unit/businesslayer/FolderBusinessLayerTest.php21
-rw-r--r--tests/unit/controller/FeedControllerTest.php6
-rw-r--r--tests/unit/controller/FolderControllerTest.php4
-rw-r--r--tests/unit/db/FeedMapperTest.php16
-rw-r--r--tests/unit/db/FolderMapperTest.php17
-rw-r--r--tests/unit/external/FeedAPITest.php6
-rw-r--r--tests/unit/external/FolderAPITest.php4
8 files changed, 82 insertions, 12 deletions
diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php
index 882106693..9f8683d9b 100644
--- a/tests/unit/businesslayer/FeedBusinessLayerTest.php
+++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php
@@ -740,4 +740,24 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
}
+ public function testPurgeDeletedWithoutInterval(){
+ $feed1 = new Feed();
+ $feed1->setId(3);
+ $feed2 = new Feed();
+ $feed2->setId(5);
+ $feeds = array($feed1, $feed2);
+
+ $this->feedMapper->expects($this->once())
+ ->method('getToDelete')
+ ->with($this->equalTo(null), $this->equalTo($this->user))
+ ->will($this->returnValue($feeds));
+ $this->feedMapper->expects($this->at(1))
+ ->method('delete')
+ ->with($this->equalTo($feed1));
+ $this->feedMapper->expects($this->at(2))
+ ->method('delete')
+ ->with($this->equalTo($feed2));
+
+ $this->feedBusinessLayer->purgeDeleted($this->user, false);
+ }
}
diff --git a/tests/unit/businesslayer/FolderBusinessLayerTest.php b/tests/unit/businesslayer/FolderBusinessLayerTest.php
index 1e26f0226..35886b626 100644
--- a/tests/unit/businesslayer/FolderBusinessLayerTest.php
+++ b/tests/unit/businesslayer/FolderBusinessLayerTest.php
@@ -232,4 +232,25 @@ class FolderBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$this->folderBusinessLayer->purgeDeleted($this->user);
}
+
+ public function testPurgeDeletedNoInterval(){
+ $folder1 = new Folder();
+ $folder1->setId(3);
+ $folder2 = new Folder();
+ $folder2->setId(5);
+ $feeds = array($folder1, $folder2);
+
+ $this->folderMapper->expects($this->once())
+ ->method('getToDelete')
+ ->with($this->equalTo(null), $this->equalTo($this->user))
+ ->will($this->returnValue($feeds));
+ $this->folderMapper->expects($this->at(1))
+ ->method('delete')
+ ->with($this->equalTo($folder1));
+ $this->folderMapper->expects($this->at(2))
+ ->method('delete')
+ ->with($this->equalTo($folder2));
+
+ $this->folderBusinessLayer->purgeDeleted($this->user, false);
+ }
}
diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php
index 841ba5ea2..370158822 100644
--- a/tests/unit/controller/FeedControllerTest.php
+++ b/tests/unit/controller/FeedControllerTest.php
@@ -318,7 +318,7 @@ class FeedControllerTest extends ControllerTestUtility {
->will($this->returnValue($result['newestItemId']));
$this->feedBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->feedBusinessLayer->expects($this->once())
->method('create')
->with($this->equalTo($post['url']),
@@ -349,7 +349,7 @@ class FeedControllerTest extends ControllerTestUtility {
->will($this->returnValue($this->user));
$this->feedBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->itemBusinessLayer->expects($this->once())
->method('getNewestItemId')
@@ -377,7 +377,7 @@ class FeedControllerTest extends ControllerTestUtility {
->will($this->returnValue($this->user));
$this->feedBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->feedBusinessLayer->expects($this->once())
->method('create')
->will($this->throwException($ex));
diff --git a/tests/unit/controller/FolderControllerTest.php b/tests/unit/controller/FolderControllerTest.php
index 64df7dc16..ff1a16a13 100644
--- a/tests/unit/controller/FolderControllerTest.php
+++ b/tests/unit/controller/FolderControllerTest.php
@@ -240,7 +240,7 @@ class FolderControllerTest extends ControllerTestUtility {
->will($this->returnValue($this->user));
$this->folderBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->folderBusinessLayer->expects($this->once())
->method('create')
->with($this->equalTo($post['folderName']),
@@ -262,7 +262,7 @@ class FolderControllerTest extends ControllerTestUtility {
->will($this->returnValue($this->user));
$this->folderBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->folderBusinessLayer->expects($this->once())
->method('create')
->will($this->throwException($ex));
diff --git a/tests/unit/db/FeedMapperTest.php b/tests/unit/db/FeedMapperTest.php
index 6894e16d0..460156e5c 100644
--- a/tests/unit/db/FeedMapperTest.php
+++ b/tests/unit/db/FeedMapperTest.php
@@ -289,7 +289,7 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$deleteOlderThan = 110;
$sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
'WHERE `deleted_at` > 0 ' .
- 'AND `deleted_at` < ?';
+ 'AND `deleted_at` < ? ';
$this->setMapperResult($sql, array($deleteOlderThan), $rows);
$result = $this->mapper->getToDelete($deleteOlderThan);
@@ -314,4 +314,18 @@ class FeedMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
}
+ public function testGetAllPurgeDeletedFromUser(){
+ $rows = array(
+ array('id' => $this->feeds[0]->getId()),
+ array('id' => $this->feeds[1]->getId())
+ );
+ $deleteOlderThan = 110;
+ $sql = 'SELECT * FROM `*PREFIX*news_feeds` ' .
+ 'WHERE `deleted_at` > 0 ' .
+ 'AND `user_id` = ?';
+ $this->setMapperResult($sql, array($this->user), $rows);
+ $result = $this->mapper->getToDelete(null, $this->user);
+
+ $this->assertEquals($this->feeds, $result);
+ }
}
diff --git a/tests/unit/db/FolderMapperTest.php b/tests/unit/db/FolderMapperTest.php
index 87726b893..d31a014a6 100644
--- a/tests/unit/db/FolderMapperTest.php
+++ b/tests/unit/db/FolderMapperTest.php
@@ -187,7 +187,7 @@ class FolderMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
$deleteOlderThan = 110;
$sql = 'SELECT * FROM `*PREFIX*news_folders` ' .
'WHERE `deleted_at` > 0 ' .
- 'AND `deleted_at` < ?';
+ 'AND `deleted_at` < ? ';
$this->setMapperResult($sql, array($deleteOlderThan), $rows);
$result = $this->folderMapper->getToDelete($deleteOlderThan);
@@ -213,4 +213,19 @@ class FolderMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
}
+ public function testGetAllPurgeDeletedUser(){
+ $rows = array(
+ array('id' => $this->folders[0]->getId()),
+ array('id' => $this->folders[1]->getId())
+ );
+ $deleteOlderThan = 110;
+ $sql = 'SELECT * FROM `*PREFIX*news_folders` ' .
+ 'WHERE `deleted_at` > 0 ' .
+ 'AND `user_id` = ?';
+ $this->setMapperResult($sql, array($this->user), $rows);
+ $result = $this->folderMapper->getToDelete(null, $this->user);
+
+ $this->assertEquals($this->folders, $result);
+ }
+
} \ No newline at end of file
diff --git a/tests/unit/external/FeedAPITest.php b/tests/unit/external/FeedAPITest.php
index c6d8247f5..cdc04bf0c 100644
--- a/tests/unit/external/FeedAPITest.php
+++ b/tests/unit/external/FeedAPITest.php
@@ -211,7 +211,7 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase {
$this->feedBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->feedBusinessLayer->expects($this->once())
->method('create')
->with(
@@ -253,7 +253,7 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase {
$this->feedBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->feedBusinessLayer->expects($this->once())
->method('create')
->with(
@@ -280,7 +280,7 @@ class FeedAPITest extends \PHPUnit_Framework_TestCase {
public function testCreateExists() {
$this->feedBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->feedBusinessLayer->expects($this->once())
->method('create')
->will($this->throwException(new BusinessLayerExistsException($this->msg)));
diff --git a/tests/unit/external/FolderAPITest.php b/tests/unit/external/FolderAPITest.php
index aaae2d084..1ae4bd081 100644
--- a/tests/unit/external/FolderAPITest.php
+++ b/tests/unit/external/FolderAPITest.php
@@ -114,7 +114,7 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase {
$this->folderBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->folderBusinessLayer->expects($this->once())
->method('create')
->with($this->equalTo($folderName), $this->equalTo($this->user))
@@ -132,7 +132,7 @@ class FolderAPITest extends \PHPUnit_Framework_TestCase {
$msg = 'exists';
$this->folderBusinessLayer->expects($this->once())
->method('purgeDeleted')
- ->with($this->equalTo($this->user));
+ ->with($this->equalTo($this->user), $this->equalTo(false));
$this->folderBusinessLayer->expects($this->once())
->method('create')
->will($this->throwException(new BusinessLayerExistsException($msg)));