File: FunctionalTestCase.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 (72 lines) | stat: -rw-r--r-- 2,052 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
<?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\App\Helpers;

use Composer\XdebugHandler\Tests\App\Framework\AppRunner;
use Composer\XdebugHandler\Tests\App\Framework\LogItem;
use Composer\XdebugHandler\Tests\App\Framework\Logs;
use PHPUnit\Framework\TestCase;

abstract class FunctionalTestCase extends TestCase
{
    /** @var AppRunner */
    protected $runner;

    protected function setUp(): void
    {
        $scriptDir = dirname(__DIR__);
        $this->runner = new AppRunner($scriptDir);
    }

    /**
     * @param-out string $actual
     */
    protected function compareXdebugVersion(string $version, string $op, ?string &$actual): bool
    {
        $actual = (string) phpversion('xdebug');
        return version_compare($actual, $version, $op);
    }

    protected function checkRestart(Logs $logs, ?int $childCount = null): void
    {
        $main = $logs->getValuesForProcess(1);
        $child = $logs->getValuesForProcess(2);

        self::assertCount(5, $main);

        $count = $childCount === null ? 2 : $childCount;
        self::assertCount($count, $child);

        if ($childCount === null) {
            $item = $logs->getItemFromList($child, 2);
            self::assertStringContainsString('The Xdebug extension is not loaded', $item);
        }
    }

    protected function checkNoRestart(Logs $logs, ?string $extraExpected = null): void
    {
        $main = $logs->getValuesForProcess(1);
        $child = $logs->getValuesForProcess(2);

        self::assertCount(3, $main);
        self::assertCount(0, $child);

        $item = $logs->getItemFromList($main, 3);
        self::assertStringContainsString('No restart', $item);

        if ($extraExpected !== null) {
            self::assertStringContainsString($extraExpected, $item);
        }
    }
}