diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-19 18:13:54 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-19 18:13:54 +0100 |
commit | 794120c0f6cc933e89782262cbb71efd668f8cb8 (patch) | |
tree | fd4dd568cfdb9525dd11e094ff52e33880ab4943 /tests/unit | |
parent | b6a4a8a29b37c8b3f7124285ae21e32bf06a8f5c (diff) |
allow to change the explore service url
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/config/ConfigTest.php | 4 | ||||
-rw-r--r-- | tests/unit/controller/AdminControllerTest.php | 16 | ||||
-rw-r--r-- | tests/unit/controller/PageControllerTest.php | 64 |
3 files changed, 78 insertions, 6 deletions
diff --git a/tests/unit/config/ConfigTest.php b/tests/unit/config/ConfigTest.php index bdffeb0d1..5baeae3ba 100644 --- a/tests/unit/config/ConfigTest.php +++ b/tests/unit/config/ConfigTest.php @@ -50,6 +50,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(null, $this->config->getProxyAuth()); $this->assertEquals('', $this->config->getProxyUser()); $this->assertEquals('', $this->config->getProxyPassword()); + $this->assertEquals('', $this->config->getExploreUrl()); $this->assertEquals(1024*1024*100, $this->config->getMaxSize()); } @@ -131,6 +132,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { 'autoPurgeCount = 3' . "\n" . 'maxRedirects = 10' . "\n" . 'maxSize = 399' . "\n" . + 'exploreUrl = http://google.de' . "\n" . 'feedFetcherTimeout = 60' . "\n" . 'useCronUpdates = true'; $this->config->setAutoPurgeCount(3); @@ -139,6 +141,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $this->config->setProxyUser('this is a test'); $this->config->setProxyPassword('se'); $this->config->setMaxSize(399); + $this->config->setExploreUrl('http://google.de'); $this->fileSystem->expects($this->once()) ->method('file_put_contents') @@ -166,6 +169,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { 'autoPurgeCount = 200' . "\n" . 'maxRedirects = 10' . "\n" . 'maxSize = 104857600' . "\n" . + 'exploreUrl = ' . "\n" . 'feedFetcherTimeout = 60' . "\n" . 'useCronUpdates = false'; diff --git a/tests/unit/controller/AdminControllerTest.php b/tests/unit/controller/AdminControllerTest.php index 347e0a4a5..da6e40e36 100644 --- a/tests/unit/controller/AdminControllerTest.php +++ b/tests/unit/controller/AdminControllerTest.php @@ -48,7 +48,8 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { 'maxRedirects' => 3, 'feedFetcherTimeout' => 4, 'useCronUpdates' => 5, - 'maxSize' => 7 + 'maxSize' => 7, + 'exploreUrl' => 'test' ]; $this->config->expects($this->once()) ->method('getAutoPurgeMinimumInterval') @@ -68,6 +69,9 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { $this->config->expects($this->once()) ->method('getMaxSize') ->will($this->returnValue($expected['maxSize'])); + $this->config->expects($this->once()) + ->method('getExploreUrl') + ->will($this->returnValue($expected['exploreUrl'])); $response = $this->controller->index(); $data = $response->getParams(); @@ -88,6 +92,7 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { 'feedFetcherTimeout' => 4, 'useCronUpdates' => 5, 'maxSize' => 7, + 'exploreUrl' => 'test' ]; $this->config->expects($this->once()) @@ -106,6 +111,9 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { ->method('setUseCronUpdates') ->with($this->equalTo($expected['useCronUpdates'])); $this->config->expects($this->once()) + ->method('setExploreUrl') + ->with($this->equalTo($expected['exploreUrl'])); + $this->config->expects($this->once()) ->method('write') ->with($this->equalTo($this->configPath)); @@ -127,6 +135,9 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { $this->config->expects($this->once()) ->method('getMaxSize') ->will($this->returnValue($expected['maxSize'])); + $this->config->expects($this->once()) + ->method('getExploreUrl') + ->will($this->returnValue($expected['exploreUrl'])); $response = $this->controller->update( $expected['autoPurgeMinimumInterval'], @@ -134,7 +145,8 @@ class AdminControllerTest extends \PHPUnit_Framework_TestCase { $expected['maxRedirects'], $expected['feedFetcherTimeout'], $expected['maxSize'], - $expected['useCronUpdates'] + $expected['useCronUpdates'], + $expected['exploreUrl'] ); $this->assertEquals($expected, $response); diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php index 8f00079a3..3b3a38782 100644 --- a/tests/unit/controller/PageControllerTest.php +++ b/tests/unit/controller/PageControllerTest.php @@ -143,6 +143,7 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { 'preventReadOnScroll' => true, 'oldestFirst' => true, 'language' => 'de', + 'exploreUrl' => 'test' ] ]; @@ -173,12 +174,70 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { $this->equalTo($this->appName), $this->equalTo('oldestFirst')) ->will($this->returnValue('1')); + $this->config->expects($this->once()) + ->method('getExploreUrl') + ->will($this->returnValue(' ')); + $this->urlGenerator->expects($this->once()) + ->method('getAbsoluteURL') + ->with($this->equalTo('/index.php/apps/news/explore')) + ->will($this->returnValue('test')); + $response = $this->controller->settings(); $this->assertEquals($result, $response); } + public function testSettingsExploreUrlSet() { + $result = [ + 'settings' => [ + 'showAll' => true, + 'compact' => true, + 'preventReadOnScroll' => true, + 'oldestFirst' => true, + 'language' => 'de', + 'exploreUrl' => 'abc' + ] + ]; + + $this->l10n->expects($this->once()) + ->method('getLanguageCode') + ->will($this->returnValue('de')); + $this->settings->expects($this->at(0)) + ->method('getUserValue') + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('showAll')) + ->will($this->returnValue('1')); + $this->settings->expects($this->at(1)) + ->method('getUserValue') + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('compact')) + ->will($this->returnValue('1')); + $this->settings->expects($this->at(2)) + ->method('getUserValue') + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('preventReadOnScroll')) + ->will($this->returnValue('1')); + $this->settings->expects($this->at(3)) + ->method('getUserValue') + ->with($this->equalTo($this->user), + $this->equalTo($this->appName), + $this->equalTo('oldestFirst')) + ->will($this->returnValue('1')); + $this->config->expects($this->once()) + ->method('getExploreUrl') + ->will($this->returnValue('abc')); + $this->urlGenerator->expects($this->never()) + ->method('getAbsoluteURL'); + + + $response = $this->controller->settings(); + $this->assertEquals($result, $response); + } + public function testUpdateSettings() { $this->settings->expects($this->at(0)) ->method('setUserValue') @@ -246,9 +305,6 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { $this->equalTo($this->appName), $this->equalTo('lastViewedFeedType'), $this->equalTo(FeedType::EXPLORE)); - $this->l10n->expects($this->once()) - ->method('getLanguageCode') - ->will($this->returnValue('de_DE')); $this->recommended->expects($this->once()) ->method('forLanguage') @@ -256,7 +312,7 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { ->will($this->returnValue($in)); - $out = $this->controller->explore(); + $out = $this->controller->explore('de_DE'); $this->assertEquals($in, $out); } |