summaryrefslogtreecommitdiffstats
path: root/tests/Unit/Config/ConfigTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Unit/Config/ConfigTest.php')
-rw-r--r--tests/Unit/Config/ConfigTest.php83
1 files changed, 54 insertions, 29 deletions
diff --git a/tests/Unit/Config/ConfigTest.php b/tests/Unit/Config/ConfigTest.php
index da9dd4522..42d3c6e62 100644
--- a/tests/Unit/Config/ConfigTest.php
+++ b/tests/Unit/Config/ConfigTest.php
@@ -5,10 +5,10 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Alessandro Cosentino 2012
- * @copyright Bernhard Posselt 2012, 2014
+ * @author Alessandro Cosentino <cosenal@gmail.com>
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright 2012 Alessandro Cosentino
+ * @copyright 2012-2014 Bernhard Posselt
*/
namespace OCA\News\Tests\Unit\Config;
@@ -17,16 +17,19 @@ use OCA\News\Config\Config;
use PHPUnit_Framework_TestCase;
-class ConfigTest extends PHPUnit_Framework_TestCase {
+class ConfigTest extends PHPUnit_Framework_TestCase
+{
private $fileSystem;
private $config;
private $configPath;
private $loggerParams;
- public function setUp() {
+ public function setUp()
+ {
$this->logger = $this->getMockBuilder(
- 'OCP\ILogger')
+ 'OCP\ILogger'
+ )
->disableOriginalConstructor()
->getMock();
$this->fileSystem = $this->getMockBuilder('OCP\Files\Folder')->getMock();
@@ -38,7 +41,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
}
- public function testDefaults() {
+ public function testDefaults()
+ {
$this->assertEquals(60, $this->config->getAutoPurgeMinimumInterval());
$this->assertEquals(200, $this->config->getAutoPurgeCount());
$this->assertEquals(10, $this->config->getMaxRedirects());
@@ -49,7 +53,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
}
- public function testRead () {
+ public function testRead()
+ {
$file = $this->getMockBuilder('OCP\Files\File')->getMock();
$this->fileSystem->expects($this->once())
->method('get')
@@ -57,9 +62,11 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
->will($this->returnValue($file));
$file->expects($this->once())
->method('getContent')
- ->will($this->returnValue(
- 'autoPurgeCount = 3' . "\n" . 'useCronUpdates = true'
- ));
+ ->will(
+ $this->returnValue(
+ 'autoPurgeCount = 3' . "\n" . 'useCronUpdates = true'
+ )
+ );
$this->config->read($this->configPath);
@@ -69,7 +76,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
}
- public function testReadIgnoresVeryLowPurgeInterval () {
+ public function testReadIgnoresVeryLowPurgeInterval()
+ {
$file = $this->getMockBuilder('OCP\Files\File')->getMock();
$this->fileSystem->expects($this->once())
->method('get')
@@ -86,7 +94,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
- public function testReadBool () {
+ public function testReadBool()
+ {
$file = $this->getMockBuilder('OCP\Files\File')->getMock();
$this->fileSystem->expects($this->once())
->method('get')
@@ -94,8 +103,10 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
->will($this->returnValue($file));
$file->expects($this->once())
->method('getContent')
- ->will($this->returnValue(
- 'autoPurgeCount = 3' . "\n" . 'useCronUpdates = false')
+ ->will(
+ $this->returnValue(
+ 'autoPurgeCount = 3' . "\n" . 'useCronUpdates = false'
+ )
);
$this->config->read($this->configPath);
@@ -105,7 +116,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
}
- public function testReadLogsInvalidValue() {
+ public function testReadLogsInvalidValue()
+ {
$file = $this->getMockBuilder('OCP\Files\File')->getMock();
$this->fileSystem->expects($this->once())
->method('get')
@@ -116,15 +128,20 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
->will($this->returnValue('autoPurgeCounts = 3'));
$this->logger->expects($this->once())
->method('warning')
- ->with($this->equalTo('Configuration value "autoPurgeCounts" ' .
- 'does not exist. Ignored value.'),
- $this->equalTo($this->loggerParams));
+ ->with(
+ $this->equalTo(
+ 'Configuration value "autoPurgeCounts" ' .
+ 'does not exist. Ignored value.'
+ ),
+ $this->equalTo($this->loggerParams)
+ );
$this->config->read($this->configPath);
}
- public function testReadLogsInvalidINI() {
+ public function testReadLogsInvalidINI()
+ {
$file = $this->getMockBuilder('OCP\Files\File')->getMock();
$this->fileSystem->expects($this->once())
->method('get')
@@ -135,14 +152,17 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
->will($this->returnValue(''));
$this->logger->expects($this->once())
->method('warning')
- ->with($this->equalTo('Configuration invalid. Ignoring values.'),
- $this->equalTo($this->loggerParams));
+ ->with(
+ $this->equalTo('Configuration invalid. Ignoring values.'),
+ $this->equalTo($this->loggerParams)
+ );
$this->config->read($this->configPath);
}
- public function testWrite () {
+ public function testWrite()
+ {
$json = 'autoPurgeMinimumInterval = 60' . "\n" .
'autoPurgeCount = 3' . "\n" .
'maxRedirects = 10' . "\n" .
@@ -168,7 +188,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
- public function testReadingNonExistentConfigWillWriteDefaults() {
+ public function testReadingNonExistentConfigWillWriteDefaults()
+ {
$this->fileSystem->expects($this->once())
->method('nodeExists')
->with($this->equalTo($this->configPath))
@@ -200,7 +221,8 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
}
- public function testNoLowMinimumAutoPurgeInterval() {
+ public function testNoLowMinimumAutoPurgeInterval()
+ {
$this->config->setAutoPurgeMinimumInterval(59);
$interval = $this->config->getAutoPurgeMinimumInterval();
@@ -208,21 +230,24 @@ class ConfigTest extends PHPUnit_Framework_TestCase {
}
- public function testMinimumAutoPurgeInterval() {
+ public function testMinimumAutoPurgeInterval()
+ {
$this->config->setAutoPurgeMinimumInterval(61);
$interval = $this->config->getAutoPurgeMinimumInterval();
$this->assertSame(61, $interval);
}
- public function testMaxRedirects() {
+ public function testMaxRedirects()
+ {
$this->config->setMaxRedirects(21);
$redirects = $this->config->getMaxRedirects();
$this->assertSame(21, $redirects);
}
- public function testFeedFetcherTimeout() {
+ public function testFeedFetcherTimeout()
+ {
$this->config->setFeedFetcherTimeout(2);
$timout = $this->config->getFeedFetcherTimeout();