Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • FileSystem
  • HttpResponse
  • Imap
  • JsonRpc
  • Memcached
  • Mysql
  • Pgsql
  • PhpExtension
  • PhpVersion
  • PhpZend
  • Smtp
  • Webdav
  • XmlRpc
  • Overview
  • Namespace
  • 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: namespace Jyxo\Beholder\TestCase;
 15: 
 16: /**
 17:  * Tests Zend Framework availability and optionally its version.
 18:  *
 19:  * @category Jyxo
 20:  * @package Jyxo\Beholder
 21:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
 22:  * @license https://github.com/jyxo/php/blob/master/license.txt
 23:  * @author Jaroslav HanslĂ­k
 24:  */
 25: class PhpZend extends \Jyxo\Beholder\TestCase
 26: {
 27:     /**
 28:      * Required version.
 29:      *
 30:      * @var string
 31:      */
 32:     private $version;
 33: 
 34:     /**
 35:      * Comparison operator: <, >, =, <=, >=.
 36:      *
 37:      * @var string
 38:      */
 39:     private $comparison;
 40: 
 41:     /**
 42:      * Constructor.
 43:      *
 44:      * @param string $description Test description
 45:      * @param string $version Required version
 46:      * @param string $comparison Comparison operator
 47:      */
 48:     public function __construct($description, $version = '', $comparison = '=')
 49:     {
 50:         parent::__construct($description);
 51: 
 52:         $this->version = (string) $version;
 53:         $this->comparison = (string) $comparison;
 54:     }
 55: 
 56:     /**
 57:      * Performs the test.
 58:      *
 59:      * @return \Jyxo\Beholder\Result
 60:      */
 61:     public function run()
 62:     {
 63:         // Zend Framework availability
 64:         if (!class_exists('\Zend_Version')) {
 65:             return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, 'Zend framework missing');
 66:         }
 67: 
 68:         $result = \Jyxo\Beholder\Result::SUCCESS;
 69: 
 70:         // Version comparison if requested
 71: 
 72:         if (!empty($this->version)) {
 73: 
 74:             $comparison = \Zend_Version::compareVersion($this->version);
 75: 
 76:             switch ($this->comparison) {
 77:                 case '<':
 78:                     $result = ($comparison > 0) ? \Jyxo\Beholder\Result::SUCCESS : \Jyxo\Beholder\Result::FAILURE;
 79:                     break;
 80: 
 81:                 case '<=':
 82:                     $result = ($comparison >= 0) ? \Jyxo\Beholder\Result::SUCCESS : \Jyxo\Beholder\Result::FAILURE;
 83:                     break;
 84: 
 85:                 case '>=':
 86:                     $result = ($comparison <= 0) ? \Jyxo\Beholder\Result::SUCCESS : \Jyxo\Beholder\Result::FAILURE;
 87:                     break;
 88: 
 89:                 case '>':
 90:                     $result = ($comparison < 0) ? \Jyxo\Beholder\Result::SUCCESS : \Jyxo\Beholder\Result::FAILURE;
 91:                     break;
 92: 
 93:                 default:
 94:                     $this->comparison = '=';
 95:                     $result = ($comparison === 0) ? \Jyxo\Beholder\Result::SUCCESS : \Jyxo\Beholder\Result::FAILURE;
 96:                     break;
 97:             }
 98: 
 99:             return new \Jyxo\Beholder\Result($result, sprintf('Version %s, expected %s %s', \Zend_Version::VERSION, $this->comparison, $this->version));
100: 
101:         }
102: 
103:         // OK
104:         return new \Jyxo\Beholder\Result($result, sprintf('Version %s', \Zend_Version::VERSION));
105:     }
106: }
107: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0