Overview

Packages

  • Jyxo_Beholder
  • Jyxo_Charset
  • Jyxo_Color
  • Jyxo_Css
  • Jyxo_ErrorHandling
  • Jyxo_FirePhp
  • Jyxo_Gettext
    • Parser
  • Jyxo_Html
  • Jyxo_Input
    • Chain
    • Filter
    • Validator
  • Jyxo_Mail
    • Email
    • Parser
    • Sender
  • Jyxo_Rpc
    • Json
    • Xml
  • Jyxo_Shell
  • Jyxo_SpamFilter
  • Jyxo_Spl
  • Jyxo_String
  • Jyxo_Svn
  • Jyxo_Time
  • Jyxo_Timer
  • Jyxo_Webdav
  • Jyxo_XmlReader
  • PHP

Classes

  • Jyxo_Beholder_Executor
  • Jyxo_Beholder_Result
  • Jyxo_Beholder_TestCase
  • Jyxo_Beholder_TestCase_FileSystem
  • Jyxo_Beholder_TestCase_HttpResponse
  • Jyxo_Beholder_TestCase_Imap
  • Jyxo_Beholder_TestCase_JsonRpc
  • Jyxo_Beholder_TestCase_Memcached
  • Jyxo_Beholder_TestCase_Mysql
  • Jyxo_Beholder_TestCase_Pgsql
  • Jyxo_Beholder_TestCase_PhpExtension
  • Jyxo_Beholder_TestCase_PhpVersion
  • Jyxo_Beholder_TestCase_PhpZend
  • Jyxo_Beholder_TestCase_Smtp
  • Jyxo_Beholder_TestCase_Webdav
  • Jyxo_Beholder_TestCase_XmlRpc
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * Jyxo PHP Library
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file license.txt.
10:  * It is also available through the world-wide-web at this URL:
11:  * https://github.com/jyxo/php/blob/master/license.txt
12:  */
13: 
14: /**
15:  * Tests the current PHP version.
16:  *
17:  * @category Jyxo
18:  * @package Jyxo_Beholder
19:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
20:  * @license https://github.com/jyxo/php/blob/master/license.txt
21:  * @author Jaroslav HanslĂ­k
22:  */
23: class Jyxo_Beholder_TestCase_PhpVersion extends Jyxo_Beholder_TestCase
24: {
25:     /**
26:      * Required version.
27:      *
28:      * @var string
29:      */
30:     private $version;
31: 
32:     /**
33:      * Optional extension test.
34:      *
35:      * @var string
36:      */
37:     private $extension;
38: 
39:     /**
40:      * Comparison type.
41:      *
42:      * @var string
43:      */
44:     private $comparison;
45: 
46:     /**
47:      * Constructor.
48:      *
49:      * @param string $description Test description
50:      * @param string $version Required version
51:      * @param string $extension Optional extension name
52:      * @param string $comparison Comparison operator for version_compare. >= means "the actual version must be greater or equal to the expected"
53:      */
54:     public function __construct($description, $version, $extension = '', $comparison = '=')
55:     {
56:         parent::__construct($description);
57: 
58:         $this->version = (string) $version;
59:         $this->extension = (string) $extension;
60:         $this->comparison = (string) $comparison;
61:     }
62: 
63:     /**
64:      * Performs the test.
65:      *
66:      * @return Jyxo_Beholder_Result
67:      */
68:     public function run()
69:     {
70:         // If we test extensions they have to be installed
71:         if ((!empty($this->extension)) && (!extension_loaded($this->extension))) {
72:             return new Jyxo_Beholder_Result(Jyxo_Beholder_Result::NOT_APPLICABLE, sprintf('Extension %s missing', $this->extension));
73:         }
74: 
75:         // Current version
76:         $actual = !empty($this->extension) ? phpversion($this->extension) : phpversion();
77: 
78:         // Version comparison
79:         if (true !== version_compare($actual, $this->version, $this->comparison)) {
80:             return new Jyxo_Beholder_Result(Jyxo_Beholder_Result::FAILURE, sprintf('Version %s, expected %s %s', $actual, $this->comparison, $this->version));
81:         }
82: 
83:         // OK
84:         return new Jyxo_Beholder_Result(Jyxo_Beholder_Result::SUCCESS, sprintf('Version %s', $actual));
85:     }
86: }
87: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0