-
-
Notifications
You must be signed in to change notification settings - Fork 375
Expand file tree
/
Copy pathSourcePatcherTest.php
More file actions
70 lines (56 loc) · 1.86 KB
/
SourcePatcherTest.php
File metadata and controls
70 lines (56 loc) · 1.86 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
declare(strict_types=1);
namespace SPC\Tests\store;
use PHPUnit\Framework\TestCase;
use SPC\store\SourcePatcher;
/**
* @internal
*/
class SourcePatcherTest extends TestCase
{
private string $defDir;
private string $defFile;
private string $libDir;
private string $libFile;
protected function setUp(): void
{
// Create fake php-src/ext/libxml directory under SOURCE_PATH
$this->defDir = SOURCE_PATH . '/php-src/ext/libxml';
if (!is_dir($this->defDir)) {
mkdir($this->defDir, 0755, true);
}
$this->defFile = $this->defDir . '/php_libxml2.def';
// Create fake buildroot/lib directory
$this->libDir = BUILD_ROOT_PATH . '/lib';
if (!is_dir($this->libDir)) {
mkdir($this->libDir, 0755, true);
}
$this->libFile = $this->libDir . '/libxml2_a.lib';
}
protected function tearDown(): void
{
if (file_exists($this->defFile)) {
unlink($this->defFile);
}
if (file_exists($this->libFile)) {
unlink($this->libFile);
}
@rmdir(SOURCE_PATH . '/php-src/ext/libxml');
@rmdir(SOURCE_PATH . '/php-src/ext');
@rmdir(SOURCE_PATH . '/php-src');
}
public function testPatchLibxml2DefNoOpWhenDefFileMissing(): void
{
// No .def file — should return silently
SourcePatcher::patchLibxml2DefForWindows();
$this->assertFileDoesNotExist($this->defFile);
}
public function testPatchLibxml2DefNoOpWhenLibFileMissing(): void
{
// .def exists but no .lib — should return silently
file_put_contents($this->defFile, "EXPORTS\nxmlUCSIsArabic\n");
$original = file_get_contents($this->defFile);
SourcePatcher::patchLibxml2DefForWindows();
$this->assertEquals($original, file_get_contents($this->defFile));
}
}