From 6b138b98a6a92d31263dfcf8075e432f0df40649 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Fri, 13 Sep 2013 18:29:34 +0200 Subject: use before and after update hooks to delete items only after new ones have been fetched --- tests/unit/external/NewsAPITest.php | 23 ++++++++++++++++++----- tests/unit/utility/UpdaterTest.php | 10 +++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/unit/external/NewsAPITest.php b/tests/unit/external/NewsAPITest.php index a14faafc7..0f3031090 100644 --- a/tests/unit/external/NewsAPITest.php +++ b/tests/unit/external/NewsAPITest.php @@ -66,9 +66,14 @@ class NewsAPITest extends ControllerTestUtility { $this->assertDefaultAnnotations('version'); } - public function testCleanUpAnnotations(){ + public function testBeforeUpdateAnnotations(){ $annotations = array('Ajax', 'CSRFExemption', 'API'); - $this->assertAnnotations($this->newsAPI, 'cleanUp', $annotations); + $this->assertAnnotations($this->newsAPI, 'beforeUpdate', $annotations); + } + + public function testAfterUpdateAnnotations(){ + $annotations = array('Ajax', 'CSRFExemption', 'API'); + $this->assertAnnotations($this->newsAPI, 'afterUpdate', $annotations); } public function testGetVersion(){ @@ -85,10 +90,18 @@ class NewsAPITest extends ControllerTestUtility { } - public function testCleanUp(){ + public function testBeforeUpdate(){ + $this->updater->expects($this->once()) + ->method('beforeUpdate'); + $response = $this->newsAPI->beforeUpdate(); + $this->assertTrue($response instanceof JSONResponse); + } + + + public function testAfterUpdate(){ $this->updater->expects($this->once()) - ->method('cleanUp'); - $response = $this->newsAPI->cleanUp(); + ->method('afterUpdate'); + $response = $this->newsAPI->afterUpdate(); $this->assertTrue($response instanceof JSONResponse); } diff --git a/tests/unit/utility/UpdaterTest.php b/tests/unit/utility/UpdaterTest.php index 8a900d15e..2e6b03351 100644 --- a/tests/unit/utility/UpdaterTest.php +++ b/tests/unit/utility/UpdaterTest.php @@ -58,17 +58,21 @@ class UpdaterTest extends \PHPUnit_Framework_TestCase { $this->itemBusinessLayer); } - public function testCleanUp() { + public function testBeforeUpdate() { $this->folderBusinessLayer->expects($this->once()) ->method('purgeDeleted'); $this->feedBusinessLayer->expects($this->once()) ->method('purgeDeleted'); + $this->updater->beforeUpdate(); + } + + + public function testAfterUpdate() { $this->itemBusinessLayer->expects($this->once()) ->method('autoPurgeOld'); - $this->updater->cleanUp(); + $this->updater->afterUpdate(); } - public function testUpdate() { $this->feedBusinessLayer->expects($this->once()) ->method('updateAll'); -- cgit v1.2.3