summaryrefslogtreecommitdiffstats
path: root/tests/unit/config/AppConfigTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/config/AppConfigTest.php')
-rw-r--r--tests/unit/config/AppConfigTest.php340
1 files changed, 170 insertions, 170 deletions
diff --git a/tests/unit/config/AppConfigTest.php b/tests/unit/config/AppConfigTest.php
index 34ab2738a..01bacbf5c 100644
--- a/tests/unit/config/AppConfigTest.php
+++ b/tests/unit/config/AppConfigTest.php
@@ -16,174 +16,174 @@ namespace OCA\News\Config;
class AppConfigTest extends \PHPUnit_Framework_TestCase {
- private $nav;
- private $config;
- private $url;
-
- public function setUp() {
- $this->nav = $this->getMockBuilder('\OCP\INavigationManager')
- ->disableOriginalConstructor()
- ->getMock();
- $this->url = $this->getMockBuilder('\OCP\IURLGenerator')
- ->disableOriginalConstructor()
- ->getMock();
- $phpVersion = '5.3';
- $ownCloudVersion = '6.0.3';
- $installedExtensions = ['curl' => '4.3'];
- $databaseType = 'oracle';
-
- $this->config = new AppConfig($this->nav, $this->url, $phpVersion,
- $ownCloudVersion, $installedExtensions, $databaseType);
- }
-
- public function testGetId() {
- $this->config->loadConfig(__DIR__ . '/../../../appinfo/app.json');
- $this->assertEquals('news', $this->config->getConfig('id'));
- }
-
-
- public function testGetConfig() {
- $config = file_get_contents(__DIR__ . '/../../../appinfo/app.json');
- $config = json_decode($config, true);
- $this->config->loadConfig($config);
- $config['navigation'] = [
- 'id' => 'news',
- 'order' => 10,
- 'route' => 'news.page.index',
- 'icon' => 'app.svg',
- 'name' => 'News',
- ];
- $this->assertEquals($config, $this->config->getConfig());
- }
-
-
- public function testNoNavigation() {
- $this->config->loadConfig([]);
-
- $this->nav->expects($this->never())
- ->method('add');
- }
-
-
- public function testDefaultNavigation() {
- $expected = [
- 'id' => 'news',
- 'href' => 'news.page.index',
- 'order' => 10,
- 'icon' => 'app.svg',
- 'name' => 'News'
- ];
-
- $this->url->expects($this->once())
- ->method('linkToRoute')
- ->with($this->equalTo('news.page.index'))
- ->will($this->returnValue('news.page.index'));
-
- $this->url->expects($this->once())
- ->method('imagePath')
- ->with($this->equalTo('news'),
- $this->equalTo('app.svg'))
- ->will($this->returnValue('app.svg'));
-
- $this->nav->expects($this->once())
- ->method('add')
- ->with($this->equalTo($expected));
-
- $this->config->loadConfig([
- 'id' => 'news',
- 'name' => 'News',
- 'navigation' => []
- ]);
- $this->config->registerNavigation();
- }
-
-
- public function testCustomNavigation() {
- $expected = [
- 'id' => 'abc',
- 'href' => 'abc.page.index',
- 'order' => 1,
- 'icon' => 'test.svg',
- 'name' => 'haha'
- ];
-
- $this->url->expects($this->once())
- ->method('linkToRoute')
- ->with($this->equalTo('abc.page.index'))
- ->will($this->returnValue('abc.page.index'));
-
- $this->url->expects($this->once())
- ->method('imagePath')
- ->with($this->equalTo('abc'),
- $this->equalTo('test.svg'))
- ->will($this->returnValue('test.svg'));
-
- $this->nav->expects($this->once())
- ->method('add')
- ->with($this->equalTo($expected));
-
- $this->config->loadConfig([
- 'id' => 'abc',
- 'name' => 'News',
- 'navigation' => $expected
- ]);
- $this->config->registerNavigation();
- }
-
-
- /**
- * @expectedException \OCA\News\Config\DependencyException
- */
- public function testPHPVersion() {
- $this->config->loadConfig([
- 'dependencies' => [
- 'php' => '5.7'
- ]
- ]);
- $this->config->testDependencies();
- }
-
-
- /**
- * @expectedException \OCA\News\Config\DependencyException
- */
- public function testLibsVersion() {
- $this->config->loadConfig([
- 'dependencies' => [
- 'libs' => [
- 'curl' => '>=4.3,<=4.3'
- ]
- ]
- ]);
- $this->config->testDependencies();
- }
-
-
- /**
- * @expectedException \OCA\News\Config\DependencyException
- */
- public function testLibsExistence() {
- $this->config->loadConfig([
- 'dependencies' => [
- 'libs' => [
- 'dope' => '>=4.3,<=4.3'
- ]
- ]
- ]);
- $this->config->testDependencies();
- }
-
-
-
- /**
- * @expectedException \OCA\News\Config\DependencyException
- */
- public function testSupportedDb() {
- $this->config->loadConfig([
- 'dependencies' => [
- "databases" => ['pgsql', 'sqlite']
- ]
- ]);
- $this->config->testDependencies();
- }
+ private $nav;
+ private $config;
+ private $url;
+
+ public function setUp() {
+ $this->nav = $this->getMockBuilder('\OCP\INavigationManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->url = $this->getMockBuilder('\OCP\IURLGenerator')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $phpVersion = '5.3';
+ $ownCloudVersion = '6.0.3';
+ $installedExtensions = ['curl' => '4.3'];
+ $databaseType = 'oracle';
+
+ $this->config = new AppConfig($this->nav, $this->url, $phpVersion,
+ $ownCloudVersion, $installedExtensions, $databaseType);
+ }
+
+ public function testGetId() {
+ $this->config->loadConfig(__DIR__ . '/../../../appinfo/app.json');
+ $this->assertEquals('news', $this->config->getConfig('id'));
+ }
+
+
+ public function testGetConfig() {
+ $config = file_get_contents(__DIR__ . '/../../../appinfo/app.json');
+ $config = json_decode($config, true);
+ $this->config->loadConfig($config);
+ $config['navigation'] = [
+ 'id' => 'news',
+ 'order' => 10,
+ 'route' => 'news.page.index',
+ 'icon' => 'app.svg',
+ 'name' => 'News',
+ ];
+ $this->assertEquals($config, $this->config->getConfig());
+ }
+
+
+ public function testNoNavigation() {
+ $this->config->loadConfig([]);
+
+ $this->nav->expects($this->never())
+ ->method('add');
+ }
+
+
+ public function testDefaultNavigation() {
+ $expected = [
+ 'id' => 'news',
+ 'href' => 'news.page.index',
+ 'order' => 10,
+ 'icon' => 'app.svg',
+ 'name' => 'News'
+ ];
+
+ $this->url->expects($this->once())
+ ->method('linkToRoute')
+ ->with($this->equalTo('news.page.index'))
+ ->will($this->returnValue('news.page.index'));
+
+ $this->url->expects($this->once())
+ ->method('imagePath')
+ ->with($this->equalTo('news'),
+ $this->equalTo('app.svg'))
+ ->will($this->returnValue('app.svg'));
+
+ $this->nav->expects($this->once())
+ ->method('add')
+ ->with($this->equalTo($expected));
+
+ $this->config->loadConfig([
+ 'id' => 'news',
+ 'name' => 'News',
+ 'navigation' => []
+ ]);
+ $this->config->registerNavigation();
+ }
+
+
+ public function testCustomNavigation() {
+ $expected = [
+ 'id' => 'abc',
+ 'href' => 'abc.page.index',
+ 'order' => 1,
+ 'icon' => 'test.svg',
+ 'name' => 'haha'
+ ];
+
+ $this->url->expects($this->once())
+ ->method('linkToRoute')
+ ->with($this->equalTo('abc.page.index'))
+ ->will($this->returnValue('abc.page.index'));
+
+ $this->url->expects($this->once())
+ ->method('imagePath')
+ ->with($this->equalTo('abc'),
+ $this->equalTo('test.svg'))
+ ->will($this->returnValue('test.svg'));
+
+ $this->nav->expects($this->once())
+ ->method('add')
+ ->with($this->equalTo($expected));
+
+ $this->config->loadConfig([
+ 'id' => 'abc',
+ 'name' => 'News',
+ 'navigation' => $expected
+ ]);
+ $this->config->registerNavigation();
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testPHPVersion() {
+ $this->config->loadConfig([
+ 'dependencies' => [
+ 'php' => '5.7'
+ ]
+ ]);
+ $this->config->testDependencies();
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testLibsVersion() {
+ $this->config->loadConfig([
+ 'dependencies' => [
+ 'libs' => [
+ 'curl' => '>=4.3,<=4.3'
+ ]
+ ]
+ ]);
+ $this->config->testDependencies();
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testLibsExistence() {
+ $this->config->loadConfig([
+ 'dependencies' => [
+ 'libs' => [
+ 'dope' => '>=4.3,<=4.3'
+ ]
+ ]
+ ]);
+ $this->config->testDependencies();
+ }
+
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testSupportedDb() {
+ $this->config->loadConfig([
+ 'dependencies' => [
+ "databases" => ['pgsql', 'sqlite']
+ ]
+ ]);
+ $this->config->testDependencies();
+ }
} \ No newline at end of file