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 PHP extensions presence.
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_PhpExtension extends Jyxo_Beholder_TestCase
24: {
25: /**
26: * List of extensions.
27: *
28: * @var array
29: */
30: private $extensionList = array();
31:
32: /**
33: * Constructor.
34: *
35: * @param string $description Test description
36: * @param array $extensionList List of extensions
37: */
38: public function __construct($description, array $extensionList)
39: {
40: parent::__construct($description);
41:
42: $this->extensionList = $extensionList;
43: }
44:
45: /**
46: * Performs the test.
47: *
48: * @return Jyxo_Beholder_Result
49: */
50: public function run()
51: {
52: // Check
53: $missing = array();
54: foreach ($this->extensionList as $extension) {
55: if (!extension_loaded($extension)) {
56: $missing[] = $extension;
57: }
58: }
59:
60: // Some extensions are missing
61: if (!empty($missing)) {
62: return new Jyxo_Beholder_Result(Jyxo_Beholder_Result::FAILURE, sprintf('Missing %s', implode(', ', $missing)));
63: }
64:
65: // OK
66: return new Jyxo_Beholder_Result(Jyxo_Beholder_Result::SUCCESS);
67: }
68: }
69: