~clinton-collins/familyproject/trunk

« back to all changes in this revision

Viewing changes to ZendFramework/tests/Zend/VersionTest.php

  • Committer: Clinton Collins
  • Date: 2009-06-26 19:54:58 UTC
  • Revision ID: clinton.collins@gmail.com-20090626195458-5ebba0qcvo15xlpy
Initial Import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * Zend Framework
 
4
 *
 
5
 * LICENSE
 
6
 *
 
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.
 
14
 *
 
15
 * @category   Zend
 
16
 * @package    Zend_Version
 
17
 * @subpackage UnitTests
 
18
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
20
 * @version    $Id: VersionTest.php 11973 2008-10-15 16:00:56Z matthew $
 
21
 */
 
22
 
 
23
/**
 
24
 * Test helper
 
25
 */
 
26
require_once dirname(__FILE__) . '/../TestHelper.php';
 
27
 
 
28
/**
 
29
 * @see Zend_Version
 
30
 */
 
31
require_once 'Zend/Version.php';
 
32
 
 
33
/**
 
34
 * @category   Zend
 
35
 * @package    Zend_Version
 
36
 * @subpackage UnitTests
 
37
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
38
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
39
 */
 
40
class Zend_VersionTest extends PHPUnit_Framework_TestCase
 
41
{
 
42
    /**
 
43
     * Tests that version_compare() and its "proxy"
 
44
     * Zend_Version::compareVersion() work as expected.
 
45
     */
 
46
    public function testVersionCompare()
 
47
    {
 
48
        $expect = -1;
 
49
        // unit test breaks if ZF version > 1.x
 
50
        for ($i=0; $i <= 1; $i++) {
 
51
            for ($j=0; $j < 10; $j++) {
 
52
                for ($k=0; $k < 20; $k++) {
 
53
                    foreach (array('PR', 'dev', 'alpha', 'beta', 'RC', 'RC1', 'RC2', 'RC3', '', 'pl') as $rel) {
 
54
                        $ver = "$i.$j.$k$rel";
 
55
                        if ($ver === Zend_Version::VERSION
 
56
                            || "$i.$j.$k-$rel" === Zend_Version::VERSION
 
57
                            || "$i.$j.$k.$rel" === Zend_Version::VERSION
 
58
                            || "$i.$j.$k $rel" === Zend_Version::VERSION) {
 
59
 
 
60
                            if ($expect != -1) {
 
61
                                $this->fail("Unexpected double match for Zend_Version::VERSION ("
 
62
                                    . Zend_Version::VERSION . ")");
 
63
                            }
 
64
                            else {
 
65
                                $expect = 1;
 
66
                            }
 
67
                        } else {
 
68
                            $this->assertSame(Zend_Version::compareVersion($ver), $expect,
 
69
                                "For version '$ver' and Zend_Version::VERSION = '"
 
70
                                . Zend_Version::VERSION . "': result=" . (Zend_Version::compareVersion($ver))
 
71
                                . ', but expected ' . $expect);
 
72
                        }
 
73
                    }
 
74
                }
 
75
            }
 
76
        }
 
77
        if ($expect === -1) {
 
78
            $this->fail('Unable to recognize Zend_Version::VERSION ('. Zend_Version::VERSION . ')');
 
79
        }
 
80
    }
 
81
 
 
82
}