diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-01-14 02:07:30 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-01-14 02:07:30 +0300 |
commit | 7d15ca9a8cbcd1ee5d44a8a8db17f4d88bd66b37 (patch) | |
tree | 43db2a6549ab6e14752abc961410589d0ce6e97e /tests/PHPUnit/Unit | |
parent | 38c811e72aeb6bbbd2de5258f7435102889670d1 (diff) |
refs #6706 add link to changelog in case update is a stable update
Diffstat (limited to 'tests/PHPUnit/Unit')
-rw-r--r-- | tests/PHPUnit/Unit/VersionTest.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/VersionTest.php b/tests/PHPUnit/Unit/VersionTest.php new file mode 100644 index 0000000000..03e588d73d --- /dev/null +++ b/tests/PHPUnit/Unit/VersionTest.php @@ -0,0 +1,82 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Tests\Unit; + +use Piwik\Tests\Framework\TestCase\UnitTestCase; +use Piwik\Version; + +class VersionTest extends UnitTestCase +{ + /** + * @var Version + */ + private $version; + + public function setUp() + { + $this->version = new Version(); + } + + public function test_isStableVersion() + { + $this->assertIsStableVersion('3.3.3'); + $this->assertIsStableVersion('3.0.0'); + $this->assertIsStableVersion('100.999.9191'); + + $this->assertNotStableVersion('3.3'); + $this->assertNotStableVersion('3.3.'); + $this->assertNotStableVersion('3-3-3'); + $this->assertNotStableVersion('a3.3.3'); + $this->assertNotStableVersion('3.0.0b'); + $this->assertNotStableVersion('3.3.3-b1'); + $this->assertNotStableVersion('3.3.3-rc1'); + } + + public function test_isVersionNumber() + { + $this->assertIsVersionNumber('3.3.3'); + $this->assertIsVersionNumber('3.3.3-b1'); + $this->assertIsVersionNumber('100.999.9991-rc90'); + $this->assertIsVersionNumber('100.999.9991-b90'); + $this->assertIsVersionNumber('100.999.9991-beta90'); + + $this->assertNotVersionNumber('3.3'); + $this->assertNotVersionNumber('3.3.'); + $this->assertNotVersionNumber('3-3-3'); + $this->assertNotVersionNumber('a3.3.3'); + $this->assertNotVersionNumber('3.0.0b'); + $this->assertNotVersionNumber('3.0.0beta1'); // missing dash + $this->assertNotVersionNumber('3.3.3-bbeta1'); // max 4 allowed but bbeta is 5 + } + + private function assertIsStableVersion($versionNumber) + { + $isStable = $this->version->isStableVersion($versionNumber); + $this->assertTrue($isStable); + } + + private function assertNotStableVersion($versionNumber) + { + $isStable = $this->version->isStableVersion($versionNumber); + $this->assertFalse($isStable); + } + + private function assertIsVersionNumber($versionNumber) + { + $isStable = $this->version->isVersionNumber($versionNumber); + $this->assertTrue($isStable); + } + + private function assertNotVersionNumber($versionNumber) + { + $isStable = $this->version->isVersionNumber($versionNumber); + $this->assertFalse($isStable); + } + +} |