1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: namespace Jyxo\Beholder\TestCase;
15:
16: 17: 18: 19: 20: 21: 22: 23: 24:
25: class PhpZend extends \Jyxo\Beholder\TestCase
26: {
27: 28: 29: 30: 31:
32: private $version;
33:
34: 35: 36: 37: 38:
39: private $comparison;
40:
41: 42: 43: 44: 45: 46: 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: 58: 59: 60:
61: public function run()
62: {
63:
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:
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:
104: return new \Jyxo\Beholder\Result($result, sprintf('Version %s', \Zend_Version::VERSION));
105: }
106: }
107: