File: AppNoRestartTest.php

package info (click to toggle)
php-composer-xdebug-handler 3.0.5-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 460 kB
  • sloc: php: 2,501; makefile: 18
file content (95 lines) | stat: -rw-r--r-- 2,595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php

/*
 * This file is part of composer/xdebug-handler.
 *
 * (c) Composer <https://github.com/composer>
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

declare(strict_types=1);

namespace Composer\XdebugHandler\Tests;

use Composer\XdebugHandler\Tests\App\Framework\AppRunner;
use Composer\XdebugHandler\Tests\App\Framework\PhpOptions;
use Composer\XdebugHandler\Tests\App\Helpers\FunctionalTestCase;
use PHPUnit\Framework\TestCase;

/**
 * @group functional
 */
class AppNoRestartTest extends FunctionalTestCase
{
    /**
     * Tests no restart when env allow is truthy
     *
     * @requires extension xdebug
     */
    public function testNoRestartWhenAllowed(): void
    {
        $script = 'app-basic.php';

        $logs = $this->runner->run($script, null, true);
        $this->checkNoRestart($logs);

        $appName = $this->runner->getAppName($script);
        $child = $logs->getValuesForProcessName(1, $appName);
        $item = $logs->getItemFromList($child, 2);
        self::assertStringContainsString('The Xdebug extension is loaded', $item);
    }

    /**
     * Tests no restart when xdebug.mode is off
     *
     * @requires extension xdebug
     */
    public function testNoRestartWhenModeOff(): void
    {
        if ($this->compareXdebugVersion('3.1', '<', $version)) {
            self::markTestSkipped('Not supported in xdebug version '.$version);
        }

        $script = 'app-basic.php';

        $options = new PhpOptions();
        $options->addPhpArgs('-dxdebug.mode=off');

        $logs = $this->runner->run($script, $options);
        $this->checkNoRestart($logs, 'Allowed by xdebug.mode');
    }

    /**
     * Tests no restart when proc_open is disabled
     *
     * @requires extension xdebug
     */
    function testNoRestartWhenConfigError(): void
    {
        $script = 'app-basic.php';

        $options = new PhpOptions();
        $options->addPhpArgs('-ddisable_functions=proc_open');

        $logs = $this->runner->run($script, $options);
        $this->checkNoRestart($logs, 'proc_open function is disabled');
    }

    /**
     * Tests no restart when allowed by an application
     *
     * @requires extension xdebug
     */
    function testNoRestartWhenAllowedByApplication(): void
    {
        $script = 'app-extend-allow.php';

        $options = new PhpOptions();
        $options->addScriptArgs('--help');

        $logs = $this->runner->run($script, $options);
        $this->checkNoRestart($logs, 'Allowed by application');
    }
}