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