summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-02 17:25:05 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-02 17:25:05 +0200
commit9c9625b0f6520f80996e17304805d8bae421f44c (patch)
tree4d2e99fdab4edf3a45d3570f534f11678f7f19c4 /tests
parentc9aead3a88405e7051529c8c4e26c69b7f6369cd (diff)
add parser for app.json file, parsing jobs and hooks still left
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/config/AppConfigTest.php223
1 files changed, 223 insertions, 0 deletions
diff --git a/tests/unit/config/AppConfigTest.php b/tests/unit/config/AppConfigTest.php
new file mode 100644
index 000000000..99fba1fae
--- /dev/null
+++ b/tests/unit/config/AppConfigTest.php
@@ -0,0 +1,223 @@
+<?php
+/**
+ * ownCloud - News
+ *
+ * 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
+ */
+
+namespace OCA\News\Config;
+
+
+require_once(__DIR__ . '/../../classloader.php');
+
+
+class AppConfigTest extends \PHPUnit_Framework_TestCase {
+
+ private $nav;
+ private $config;
+ private $url;
+
+ public function setUp() {
+ $this->nav = $this->getMockBuilder('\OCP\INavigationManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->l10n = $this->getMockBuilder('\OCP\IL10N')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->url = $this->getMockBuilder('\OCP\IURLGenerator')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $phpVersion = '5.3';
+ $ownCloudVersion = '6.0.3';
+ $installedApps = array(
+ 'contacts' => '5.3',
+ 'calendar' => '2.3'
+ );
+ $installedExtensions = array(
+ 'curl' => '4.3'
+ );
+ $databaseType = 'postgresql';
+
+ $this->config = new AppConfig($this->nav, $this->l10n,
+ $this->url, $phpVersion, $ownCloudVersion, $installedApps,
+ $installedExtensions, $databaseType);
+ }
+
+ public function testGetId() {
+ $this->config->load(__DIR__ . '/../../../appinfo/app.json');
+ $this->assertEquals('news', $this->config->config['id']);
+ }
+
+
+ public function testNoNavigation() {
+ $this->config->load(array());
+
+ $this->nav->expects($this->never())
+ ->method('add');
+ }
+
+
+ public function testDefaultNavigation() {
+ $expected = array(
+ 'id' => 'news',
+ 'href' => 'news.page.index',
+ 'order' => 10,
+ 'icon' => 'app.svg',
+ 'name' => 'News'
+ );
+
+ $this->l10n->expects($this->once())
+ ->method('t')
+ ->with($this->equalTo('News'))
+ ->will($this->returnValue('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->load(array(
+ 'id' => 'news',
+ 'name' => 'News',
+ 'navigation' => array()
+ ));
+ }
+
+
+ public function testCustomNavigation() {
+ $expected = array(
+ 'id' => 'abc',
+ 'href' => 'abc.page.index',
+ 'order' => 1,
+ 'icon' => 'test.svg',
+ 'name' => 'haha'
+ );
+
+ $this->l10n->expects($this->once())
+ ->method('t')
+ ->with($this->equalTo('haha'))
+ ->will($this->returnValue('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->load(array(
+ 'id' => 'abc',
+ 'name' => 'News',
+ 'navigation' => $expected
+ ));
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testPHPVersion() {
+ $this->config->load(array(
+ 'dependencies' => array(
+ 'php' => '5.7'
+ )
+ ));
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testOwnCloudVersion() {
+ $this->config->load(array(
+ 'dependencies' => array(
+ 'owncloud' => '>=4.5,<=6.0.2'
+ )
+ ));
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testAppVersion() {
+ $this->config->load(array(
+ 'dependencies' => array(
+ 'apps' =>
+ array(
+ 'contacts' => '5.3',
+ 'calendar' => '>2.3'
+ )
+ )
+ ));
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testLibsVersion() {
+ $this->config->load(array(
+ 'dependencies' => array(
+ 'libs' =>
+ array(
+ 'curl' => '>=4.3,<=4.3'
+ )
+ )
+ ));
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testLibsExistence() {
+ $this->config->load(array(
+ 'dependencies' => array(
+ 'libs' =>
+ array(
+ 'dope' => '>=4.3,<=4.3'
+ )
+ )
+ ));
+ }
+
+
+ /**
+ * @expectedException \OCA\News\Config\DependencyException
+ */
+ public function testAppsExistence() {
+ $this->config->load(array(
+ 'dependencies' => array(
+ 'apps' =>
+ array(
+ 'news' => '>=4.3,<=4.3'
+ )
+ )
+ ));
+ }
+} \ No newline at end of file