-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExampleServerAutoloadTest.php
More file actions
51 lines (40 loc) · 1.72 KB
/
Copy pathExampleServerAutoloadTest.php
File metadata and controls
51 lines (40 loc) · 1.72 KB
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
<?php
declare(strict_types=1);
namespace Micilini\PhpSockets\Tests\Unit\Examples;
use PHPUnit\Framework\TestCase;
final class ExampleServerAutoloadTest extends TestCase
{
public function testExamplesHaveSharedBootstrapFile(): void
{
self::assertFileExists(__DIR__ . '/../../../examples/bootstrap.php');
}
public function testExampleServersUseSharedBootstrapInsteadOfLocalVendorAutoload(): void
{
$serverFiles = [
__DIR__ . '/../../../examples/easy-chat/server.php',
__DIR__ . '/../../../examples/medium-chat/server.php',
__DIR__ . '/../../../examples/private-chat/server.php',
];
foreach ($serverFiles as $serverFile) {
self::assertFileExists($serverFile);
$contents = (string) file_get_contents($serverFile);
self::assertStringContainsString(
"require __DIR__ . '/../bootstrap.php';",
$contents,
"{$serverFile} should use the shared examples bootstrap.",
);
self::assertStringNotContainsString(
'/../../vendor/autoload.php',
$contents,
"{$serverFile} should not assume a local package vendor directory.",
);
}
}
public function testSharedBootstrapSupportsRepositoryAndComposerInstallPaths(): void
{
$bootstrap = (string) file_get_contents(__DIR__ . '/../../../examples/bootstrap.php');
self::assertStringContainsString("__DIR__ . '/../vendor/autoload.php'", $bootstrap);
self::assertStringContainsString("__DIR__ . '/../../../autoload.php'", $bootstrap);
self::assertStringContainsString("getcwd() . '/vendor/autoload.php'", $bootstrap);
}
}