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

SelfTestCanSpawnProcesses   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 40
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B doTest() 0 32 4
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