Completed
Push — develop ( aae350...d9306e )
by Jaap
07:03
created

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

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
    /**
29
     * @var Process
30
     */
31
    private $webserver;
32
33
    /** @BeforeScenario         */
34
    public function gatherContexts(BeforeScenarioScope $scope)
35
    {
36
        $environment = $scope->getEnvironment();
37
38
        $this->environmentContext = $environment->getContext('phpDocumentor\Behat\Contexts\EnvironmentContext');
39
    }
40
41
    /**
42
     * @Given I open documentation
43
     */
44
    public function beforeScenario()
45
    {
46
        $workingDir = $this->environmentContext->getWorkingDir();
47
48
        $this->webserver = new Process(
49
                sprintf('php -S localhost:8080 -t %s', escapeshellarg($workingDir))
50
        );
51
52
        $this->webserver->start(function () {
53
            echo "Server started";
54
        });
55
       // sleep(1);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
56
    }
57
58
    /**
59
     * @AfterScenario
60
     */
61
    public function cleanup()
62
    {
63
        if ($this->webserver->isStarted()) {
64
            $this->webserver->stop();
65
        }
66
    }
67
}
68