summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-11-17 15:37:47 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2014-11-17 15:37:47 +0100
commit2a54eb90eee5e7358e3eebbfef871254ccbcf9e0 (patch)
tree5fd977ccc3bb83e4ec0c3eed76869e4e605ff2fc /tests
parent2667c2399e63d7c7694a9662dd92ee40d9ce4ac6 (diff)
show a warning if ajax webcron is detectedg
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/controller/PageControllerTest.php63
1 files changed, 61 insertions, 2 deletions
diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php
index 0173c3075..03d3889d3 100644
--- a/tests/unit/controller/PageControllerTest.php
+++ b/tests/unit/controller/PageControllerTest.php
@@ -25,6 +25,8 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase {
private $urlGenerator;
private $appConfig;
private $configData;
+ private $config;
+ private $adminConfig;
/**
* Gets run before each test
@@ -58,19 +60,76 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase {
'\OCP\IURLGenerator')
->disableOriginalConstructor()
->getMock();
+ $this->adminConfig = $this->getMockBuilder(
+ '\OCP\IAppConfig')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->appConfig = $this->getMockBuilder(
'\OCA\News\Config\AppConfig')
->disableOriginalConstructor()
->getMock();
+ $this->config = $this->getMockBuilder(
+ '\OCA\News\Config\Config')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->controller = new PageController($this->appName, $this->request,
- $this->settings, $this->urlGenerator, $this->appConfig, $this->l10n,
- $this->user);
+ $this->settings, $this->urlGenerator, $this->appConfig,
+ $this->adminConfig, $this->config, $this->l10n, $this->user);
}
public function testIndex(){
+ $this->config->expects($this->once())
+ ->method('getUseCronUpdates')
+ ->will($this->returnValue(true));
+
+ $this->adminConfig->expects($this->once())
+ ->method('getValue')
+ ->with(
+ $this->equalTo('core'),
+ $this->equalTo('backgroundjobs_mode')
+ )
+ ->will($this->returnValue('webcron'));
+
$response = $this->controller->index();
$this->assertEquals('index', $response->getTemplateName());
+ $this->assertSame('', $response->getParams()['cronWarning']);
+ }
+
+
+ public function testIndexNoCorrectCronAjax(){
+ $this->config->expects($this->once())
+ ->method('getUseCronUpdates')
+ ->will($this->returnValue(true));
+
+ $this->adminConfig->expects($this->once())
+ ->method('getValue')
+ ->with(
+ $this->equalTo('core'),
+ $this->equalTo('backgroundjobs_mode')
+ )
+ ->will($this->returnValue('ajax'));
+
+ $response = $this->controller->index();
+ $this->assertEquals('ajaxCron', $response->getParams()['cronWarning']);
+ }
+
+
+ public function testIndexNoCorrectCronTurnedOff(){
+ $this->config->expects($this->once())
+ ->method('getUseCronUpdates')
+ ->will($this->returnValue(false));
+
+ $this->adminConfig->expects($this->once())
+ ->method('getValue')
+ ->with(
+ $this->equalTo('core'),
+ $this->equalTo('backgroundjobs_mode')
+ )
+ ->will($this->returnValue('ajax'));
+
+ $response = $this->controller->index();
+ $this->assertSame('', $response->getParams()['cronWarning']);
}