Completed
Push — develop ( 8eb671...133594 )
by Mike
19:30 queued 09:24
created

features/bootstrap/Template/TemplateContext.php (1 issue)

Check for forgotten debug code

Debugging Code Security Critical

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author    Mike van Riel <[email protected]>
9
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
10
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
11
 * @link      http://phpdoc.org
12
 *
13
 *
14
 */
15
16
namespace phpDocumentor\Behat\Contexts\Template;
17
18
use Behat\Behat\Context\Context;
19
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
20
use phpDocumentor\Behat\Contexts\EnvironmentContext;
21
use Symfony\Component\Process\Process;
22
23
final class TemplateContext implements Context
24
{
25
    /** @var EnvironmentContext */
26
    private $environmentContext;
27
28
    /** @var Process */
29
    private $webserver;
30
31
    /** @BeforeScenario */
32
    public function gatherContexts(BeforeScenarioScope $scope)
33
    {
34
        $environment = $scope->getEnvironment();
35
36
        $this->environmentContext = $environment->getContext('phpDocumentor\Behat\Contexts\EnvironmentContext');
37
    }
38
39
    /** @BeforeScenario */
40
    public function beforeScenario()
41
    {
42
        $workingDir = $this->environmentContext->getWorkingDir();
43
44
        $this->webserver = new Process(
45
                sprintf('php -S localhost:8081 -t %s', escapeshellarg($workingDir))
46
        );
47
48
        $this->webserver->start(function () {
49
            var_dump("Server started");
0 ignored issues
show
Security Debugging Code introduced by
var_dump('Server started'); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
50
        });
51
       // sleep(1);
52
    }
53
54
    /**
55
     * @AfterScenario
56
     */
57
    public function cleanup()
58
    {
59
        if ($this->webserver->isStarted()) {
60
            $this->webserver->stop();
61
        }
62
    }
63
}
64