diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-08-16 17:49:45 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-09-24 11:58:12 +0200 |
commit | 9b652ed5d50a40a1edde0f1b8c859f49ff8248c9 (patch) | |
tree | 6f8541f68e265257bb0d7e94e87038421466fadb /tests | |
parent | 1191dda0d88c25cbc02de7752e7d9ef81b9f8b9f (diff) | |
download | nextcloud-server-9b652ed5d50a40a1edde0f1b8c859f49ff8248c9.tar.gz nextcloud-server-9b652ed5d50a40a1edde0f1b8c859f49ff8248c9.zip |
[App Code Check] add check for version and mandatory fields
* ref #17598
* including unit tests for mandatory fields/versions
Diffstat (limited to 'tests')
10 files changed, 127 insertions, 0 deletions
diff --git a/tests/apps/testapp-infoxml-version-different/appinfo/info.xml b/tests/apps/testapp-infoxml-version-different/appinfo/info.xml new file mode 100644 index 00000000000..c765400a76f --- /dev/null +++ b/tests/apps/testapp-infoxml-version-different/appinfo/info.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<info> + <id>testapp-infoxml-version</id> + <version>1.2.3</version> + <author>Jane</author> + <description>A b c</description> + <licence>Abc</licence> + <name>Test app</name> +</info> diff --git a/tests/apps/testapp-infoxml-version-different/appinfo/version b/tests/apps/testapp-infoxml-version-different/appinfo/version new file mode 100644 index 00000000000..e8ea05db814 --- /dev/null +++ b/tests/apps/testapp-infoxml-version-different/appinfo/version @@ -0,0 +1 @@ +1.2.4 diff --git a/tests/apps/testapp-infoxml-version/appinfo/info.xml b/tests/apps/testapp-infoxml-version/appinfo/info.xml new file mode 100644 index 00000000000..c765400a76f --- /dev/null +++ b/tests/apps/testapp-infoxml-version/appinfo/info.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<info> + <id>testapp-infoxml-version</id> + <version>1.2.3</version> + <author>Jane</author> + <description>A b c</description> + <licence>Abc</licence> + <name>Test app</name> +</info> diff --git a/tests/apps/testapp-infoxml-version/appinfo/version b/tests/apps/testapp-infoxml-version/appinfo/version new file mode 100644 index 00000000000..0495c4a88ca --- /dev/null +++ b/tests/apps/testapp-infoxml-version/appinfo/version @@ -0,0 +1 @@ +1.2.3 diff --git a/tests/apps/testapp-infoxml/appinfo/info.xml b/tests/apps/testapp-infoxml/appinfo/info.xml new file mode 100644 index 00000000000..cb63a0fc76e --- /dev/null +++ b/tests/apps/testapp-infoxml/appinfo/info.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<info> + <id>testapp-infoxml</id> + <version>1.2.3</version> + <author>Jane</author> + <description>A b c</description> + <licence>Abc</licence> + <name>Test app</name> +</info> diff --git a/tests/apps/testapp-name-missing/appinfo/info.xml b/tests/apps/testapp-name-missing/appinfo/info.xml new file mode 100644 index 00000000000..f0a62b8d380 --- /dev/null +++ b/tests/apps/testapp-name-missing/appinfo/info.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<info> + <id>testapp-version</id> + <version>1.1.1</version> + <author>Jane</author> + <description>A b c</description> + <licence>Abc</licence> +</info> diff --git a/tests/apps/testapp-version-missing/appinfo/info.xml b/tests/apps/testapp-version-missing/appinfo/info.xml new file mode 100644 index 00000000000..d7da3e07e36 --- /dev/null +++ b/tests/apps/testapp-version-missing/appinfo/info.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<info> + <id>testapp-version</id> + <author>Jane</author> + <description>A b c</description> + <licence>Abc</licence> + <name>Test app</name> +</info> diff --git a/tests/apps/testapp-version/appinfo/info.xml b/tests/apps/testapp-version/appinfo/info.xml new file mode 100644 index 00000000000..d7da3e07e36 --- /dev/null +++ b/tests/apps/testapp-version/appinfo/info.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<info> + <id>testapp-version</id> + <author>Jane</author> + <description>A b c</description> + <licence>Abc</licence> + <name>Test app</name> +</info> diff --git a/tests/apps/testapp-version/appinfo/version b/tests/apps/testapp-version/appinfo/version new file mode 100644 index 00000000000..0495c4a88ca --- /dev/null +++ b/tests/apps/testapp-version/appinfo/version @@ -0,0 +1 @@ +1.2.3 diff --git a/tests/lib/app/codechecker/infocheckertest.php b/tests/lib/app/codechecker/infocheckertest.php new file mode 100644 index 00000000000..59c1316b769 --- /dev/null +++ b/tests/lib/app/codechecker/infocheckertest.php @@ -0,0 +1,73 @@ +<?php +/** + * @author Morris Jobke <hey@morrisjobke.de> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OC\App\CodeChecker; + +use OC\App\InfoParser; +use Test\TestCase; + +class InfoCheckerTest extends TestCase { + /** @var InfoChecker */ + protected $infoChecker; + + public static function setUpBeforeClass() { + \OC::$APPSROOTS[] = [ + 'path' => \OC::$SERVERROOT . '/tests/apps', + 'url' => '/apps-test', + 'writable' => false, + ]; + } + + public static function tearDownAfterClass() { + // remove last element + array_pop(\OC::$APPSROOTS); + } + + protected function setUp() { + parent::setUp(); + $infoParser = new InfoParser(\OC::$server->getHTTPHelper(), \OC::$server->getURLGenerator()); + + $this->infoChecker = new InfoChecker($infoParser); + } + + public function appInfoData() { + return [ + ['testapp-infoxml', []], + ['testapp-version', []], + ['testapp-infoxml-version', []], + ['testapp-infoxml-version-different', [['type' => 'differentVersions', 'message' => 'appinfo/version: 1.2.4 - appinfo/info.xml: 1.2.3']]], + ['testapp-version-missing', [['type' => 'mandatoryFieldMissing', 'field' => 'version']]], + ['testapp-name-missing', [['type' => 'mandatoryFieldMissing', 'field' => 'name']]], + ]; + } + + /** + * @dataProvider appInfoData + * + * @param $appId + * @param $expectedErrors + */ + public function testApps($appId, $expectedErrors) { + $errors = $this->infoChecker->analyse($appId); + + $this->assertEquals($expectedErrors, $errors); + } +} |