test(namespace): extend global constant import coverage

master
韩天峰 5 days ago
parent d86d3f431d
commit 3452ddfd6e
  1. 21
      tests/compiler/namespace/use-const-single-segment.phpt

@ -1,9 +1,11 @@
--TEST-- --TEST--
use const with a single-segment (global) constant name use const with single-segment global names, aliases, and runtime constants
--FILE-- --FILE--
<?php <?php
namespace App { namespace App {
use const PHP_EOL; use const PHP_EOL;
use const PHP_EOL as LINE_END;
use const TYPEPHP_RUNTIME_SINGLE_SEGMENT as RUNTIME_VALUE;
const ANSWER = 42; const ANSWER = 42;
@ -11,6 +13,16 @@ namespace App {
{ {
return "hello" . PHP_EOL; return "hello" . PHP_EOL;
} }
function helloAlias(): string
{
return "alias" . LINE_END;
}
function runtimeValue(): string
{
return RUNTIME_VALUE;
}
} }
namespace { namespace {
@ -19,10 +31,17 @@ namespace {
function main(): void function main(): void
{ {
echo \App\hello(); echo \App\hello();
echo \App\helloAlias();
echo ANSWER, "\n"; echo ANSWER, "\n";
define('TYPEPHP_RUNTIME_SINGLE_SEGMENT', 'runtime-value');
define('RUNTIME_VALUE', 'wrong-alias-fallback');
echo \App\runtimeValue(), "\n";
} }
} }
?> ?>
--EXPECT-- --EXPECT--
hello hello
alias
42 42
runtime-value

Loading…
Cancel
Save