예제 #1
0
 /**
  * Tests that version_compare() and its "proxy"
  * Zym_Version::compareVersion() work as expected.
  */
 public function testVersionCompare()
 {
     $expect = -1;
     // unit test breaks if ZF version > 1.x
     for ($i = 0; $i <= 1; $i++) {
         for ($j = 0; $j < 10; $j++) {
             for ($k = 0; $k < 20; $k++) {
                 foreach (array('PR', 'dev', 'alpha', 'beta', 'RC', 'RC1', 'RC2', 'RC3', '', 'pl') as $rel) {
                     $ver = "{$i}.{$j}.{$k}{$rel}";
                     if ($ver === Zym_Version::VERSION || "{$i}.{$j}.{$k}-{$rel}" === Zym_Version::VERSION || "{$i}.{$j}.{$k}.{$rel}" === Zym_Version::VERSION || "{$i}.{$j}.{$k} {$rel}" === Zym_Version::VERSION) {
                         if ($expect != -1) {
                             $this->fail("Unexpected double match for Zym_Version::VERSION (" . Zym_Version::VERSION . ")");
                         } else {
                             $expect = 1;
                         }
                     } else {
                         $this->assertSame(Zym_Version::compareVersion($ver), $expect, "For version '{$ver}' and Zym_Version::VERSION = '" . Zym_Version::VERSION . "': result=" . Zym_Version::compareVersion($ver) . ', but expected ' . $expect);
                     }
                 }
             }
         }
     }
     if ($expect === -1) {
         $this->fail('Unable to recognize Zym_Version::VERSION (' . Zym_Version::VERSION . ')');
     }
 }
예제 #2
0
<?php

// returns -1, 0 or 1
$cmp = Zym_Version::compareVersion('1.0.0');