7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Version
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
23 if (!defined('PHPUnit_MAIN_METHOD')) {
24 define('PHPUnit_MAIN_METHOD', 'Zend_VersionTest::main');
30 require_once dirname(__FILE__
) . '/../TestHelper.php';
35 require_once 'Zend/Version.php';
39 * @package Zend_Version
40 * @subpackage UnitTests
41 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
42 * @license http://framework.zend.com/license/new-bsd New BSD License
45 class Zend_VersionTest
extends PHPUnit_Framework_TestCase
47 public static function main()
49 $suite = new PHPUnit_Framework_TestSuite(__CLASS__
);
50 $result = PHPUnit_TextUI_TestRunner
::run($suite);
54 * Tests that version_compare() and its "proxy"
55 * Zend_Version::compareVersion() work as expected.
57 public function testVersionCompare()
60 // unit test breaks if ZF version > 1.x
61 for ($i=0; $i <= 1; $i++
) {
62 for ($j=0; $j < 12; $j++
) {
63 for ($k=0; $k < 20; $k++
) {
64 foreach (array('dev', 'pr', 'PR', 'alpha', 'a1', 'a2', 'beta', 'b1', 'b2', 'RC', 'RC1', 'RC2', 'RC3', '', 'pl1', 'PL1') as $rel) {
65 $ver = "$i.$j.$k$rel";
66 $normalizedVersion = strtolower(Zend_Version
::VERSION
);
67 if (strtolower($ver) === $normalizedVersion
68 ||
strtolower("$i.$j.$k-$rel") === $normalizedVersion
69 ||
strtolower("$i.$j.$k.$rel") === $normalizedVersion
70 ||
strtolower("$i.$j.$k $rel") === $normalizedVersion
77 Zend_Version
::compareVersion($ver),
79 "For version '$ver' and Zend_Version::VERSION = '"
80 . Zend_Version
::VERSION
. "': result=" . (Zend_Version
::compareVersion($ver))
81 . ', but expected ' . $expect);
88 $this->fail('Unable to recognize Zend_Version::VERSION ('. Zend_Version
::VERSION
. '); last version compared: ' . $ver);
94 if (PHPUnit_MAIN_METHOD
== "Zend_VersionTest::main") {
95 Zend_VersionTest
::main();