aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/App/AppStore/Version
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/App/AppStore/Version')
-rw-r--r--tests/lib/App/AppStore/Version/VersionParserTest.php85
-rw-r--r--tests/lib/App/AppStore/Version/VersionTest.php23
2 files changed, 108 insertions, 0 deletions
diff --git a/tests/lib/App/AppStore/Version/VersionParserTest.php b/tests/lib/App/AppStore/Version/VersionParserTest.php
new file mode 100644
index 00000000000..3ccc68bc076
--- /dev/null
+++ b/tests/lib/App/AppStore/Version/VersionParserTest.php
@@ -0,0 +1,85 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace Test\App\AppStore\Version;
+
+use OC\App\AppStore\Version\Version;
+use OC\App\AppStore\Version\VersionParser;
+use Test\TestCase;
+
+class VersionParserTest extends TestCase {
+ /** @var VersionParser */
+ private $versionParser;
+
+ protected function setUp(): void {
+ parent::setUp();
+ $this->versionParser = new VersionParser();
+ }
+
+ /**
+ * @return array
+ */
+ public static function versionProvider(): array {
+ return [
+ [
+ '*',
+ new Version('', ''),
+ ],
+ [
+ '<=8.1.2',
+ new Version('', '8.1.2'),
+ ],
+ [
+ '<=9',
+ new Version('', '9'),
+ ],
+ [
+ '>=9.3.2',
+ new Version('9.3.2', ''),
+ ],
+ [
+ '>=8.1.2 <=9.3.2',
+ new Version('8.1.2', '9.3.2'),
+ ],
+ [
+ '>=8.2 <=9.1',
+ new Version('8.2', '9.1'),
+ ],
+ [
+ '>=9 <=11',
+ new Version('9', '11'),
+ ],
+ ];
+ }
+
+ /**
+ *
+ * @param string $input
+ * @param Version $expected
+ */
+ #[\PHPUnit\Framework\Attributes\DataProvider('versionProvider')]
+ public function testGetVersion($input,
+ Version $expected): void {
+ $this->assertEquals($expected, $this->versionParser->getVersion($input));
+ }
+
+
+ public function testGetVersionException(): void {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Version cannot be parsed: BogusVersion');
+
+ $this->versionParser->getVersion('BogusVersion');
+ }
+
+
+ public function testGetVersionExceptionWithMultiple(): void {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Version cannot be parsed: >=8.2 <=9.1a');
+
+ $this->versionParser->getVersion('>=8.2 <=9.1a');
+ }
+}
diff --git a/tests/lib/App/AppStore/Version/VersionTest.php b/tests/lib/App/AppStore/Version/VersionTest.php
new file mode 100644
index 00000000000..83be2be69dd
--- /dev/null
+++ b/tests/lib/App/AppStore/Version/VersionTest.php
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace Test\App\AppStore\Version;
+
+use OC\App\AppStore\Version\Version;
+use Test\TestCase;
+
+class VersionTest extends TestCase {
+ public function testGetMinimumVersion(): void {
+ $version = new Version('9', '10');
+ $this->assertSame('9', $version->getMinimumVersion());
+ }
+
+ public function testGetMaximumVersion(): void {
+ $version = new Version('9', '10');
+ $this->assertSame('10', $version->getMaximumVersion());
+ }
+}