|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +it('keeps the CompilerBase override compatible with the v0.8 native build platform contract', function (): void { |
| 6 | + $repositoryRoot = dirname(__DIR__, 2); |
| 7 | + $dockerfile = file_get_contents($repositoryRoot . '/docker/Dockerfile'); |
| 8 | + $compilerBase = file_get_contents($repositoryRoot . '/docker/CompilerBase.php'); |
| 9 | + if ($dockerfile === false || $compilerBase === false) { |
| 10 | + throw new RuntimeException('Unable to load CompilerBase Docker override files.'); |
| 11 | + } |
| 12 | + |
| 13 | + expect($dockerfile)->toContain('COPY CompilerBase.php /opt/typephp/vendor/swoole/typephp/src/CompilerBase.php'); |
| 14 | + |
| 15 | + foreach ([ |
| 16 | + 'use TypePhp\\Platform\\Ios;', |
| 17 | + 'use TypePhp\\Platform\\Android;', |
| 18 | + 'public function isIosTarget(): bool', |
| 19 | + 'return $this->getPlatform() instanceof Ios;', |
| 20 | + 'public function isAndroidTarget(): bool', |
| 21 | + 'return $this->getPlatform() instanceof Android;', |
| 22 | + 'if ($this->isIosTarget()) {', |
| 23 | + 'return $this->getIosSdkDir();', |
| 24 | + 'if ($this->isAndroidTarget()) {', |
| 25 | + 'return $this->getAndroidSdkDir();', |
| 26 | + ] as $required) { |
| 27 | + expect($compilerBase)->toContain($required); |
| 28 | + } |
| 29 | + |
| 30 | + expect($compilerBase)->toMatch( |
| 31 | + '/public function getPhpDir\(\): string\s*\{\s*if \(\$this->isIosTarget\(\)\) \{.*?' |
| 32 | + . 'return \$this->getIosSdkDir\(\);\s*}\s*if \(\$this->isAndroidTarget\(\)\) \{.*?' |
| 33 | + . 'return \$this->getAndroidSdkDir\(\);\s*}\s*try/s', |
| 34 | + ); |
| 35 | +}); |
0 commit comments