ZF-8222: format class name for class checks
[zend.git] / tests / Zend / VersionTest.php
blob4edccbe79b68880a84259fca13dbee19d8ce960b
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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
20 * @version $Id$
23 if (!defined('PHPUnit_MAIN_METHOD')) {
24 define('PHPUnit_MAIN_METHOD', 'Zend_VersionTest::main');
27 /**
28 * Test helper
30 require_once dirname(__FILE__) . '/../TestHelper.php';
32 /**
33 * @see Zend_Version
35 require_once 'Zend/Version.php';
37 /**
38 * @category Zend
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
43 * @group Zend_Version
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);
53 /**
54 * Tests that version_compare() and its "proxy"
55 * Zend_Version::compareVersion() work as expected.
57 public function testVersionCompare()
59 $expect = -1;
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
71 ) {
72 if ($expect == -1) {
73 $expect = 1;
75 } else {
76 $this->assertSame(
77 Zend_Version::compareVersion($ver),
78 $expect,
79 "For version '$ver' and Zend_Version::VERSION = '"
80 . Zend_Version::VERSION . "': result=" . (Zend_Version::compareVersion($ver))
81 . ', but expected ' . $expect);
87 if ($expect === -1) {
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();