Completed
Push — master ( 622c37...dca855 )
by Christian
04:12
created

SelfTestCanSpawnProcesses::doTest()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 32
Code Lines 17

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 32
rs 8.5806
cc 4
eloc 17
nc 4
nop 0
1
<?php
2
3
/**
4
 * This file is part of tenside/core.
5
 *
6
 * (c) Christian Schiffler <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * This project is provided in good faith and hope to be usable by anyone.
12
 *
13
 * @package    tenside/core
14
 * @author     Christian Schiffler <[email protected]>
15
 * @copyright  2015 Christian Schiffler <[email protected]>
16
 * @license    https://github.com/tenside/core/blob/master/LICENSE MIT
17
 * @link       https://github.com/tenside/core
18
 * @filesource
19
 */
20
21
namespace Tenside\Core\SelfTest\Cli;
22
23
use Tenside\Core\SelfTest\AbstractSelfTest;
24
use Tenside\Core\Util\FunctionAvailabilityCheck;
25
26
/**
27
 * This class tests that proc_open is available.
28
 */
29
class SelfTestCanSpawnProcesses extends AbstractSelfTest
30
{
31
    /**
32
     * Check that we have a correct CLI executable of PHP.
33
     *
34
     * @return void
35
     */
36
    public function doTest()
37
    {
38
        $this->setMessage('Check if PHP may spawn processes.');
39
40
        if (!FunctionAvailabilityCheck::isFunctionDefined('proc_open')) {
41
            $this->markFailed(
42
                'The process execution relies on proc_open, which is not available on your PHP installation.'
43
            );
44
45
            return;
46
        }
47
48
        if (FunctionAvailabilityCheck::isFunctionBlacklistedInSuhosin('proc_open')) {
49
            $this->markFailed(
50
                'The process execution relies on proc_open, which is disabled in Suhosin on your PHP installation. ' .
51
                'Please remove "proc_open" from "suhosin.executor.func.blacklist" in php.ini'
52
            );
53
54
            return;
55
        }
56
57
        if (FunctionAvailabilityCheck::isFunctionBlacklistedInPhpIni('proc_open')) {
58
            $this->markFailed(
59
                'The process execution relies on proc_open, which is disabled in your PHP installation. ' .
60
                'Please remove "proc_open" from "disabled_functions" in php.ini'
61
            );
62
63
            return;
64
        }
65
66
        $this->markSuccess();
67
    }
68
}
69