forked from zephir-lang/zephir
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd8ea54
commit c97da5e
Showing
2 changed files
with
84 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
|
||
namespace Test\Globals; | ||
|
||
class Server | ||
{ | ||
public function f1() -> void | ||
{ | ||
echo _SERVER["PHP_SELF"]; | ||
this->f2(); | ||
echo _SERVER["PHP_SELF"]; | ||
} | ||
/** | ||
* @see https://github.com/phalcon/zephir/issues/1961 | ||
*/ | ||
public function f1() -> void | ||
{ | ||
echo _SERVER["PHP_SELF"]; | ||
this->f2(); | ||
echo _SERVER["PHP_SELF"]; | ||
} | ||
|
||
public function f2() -> void | ||
{ | ||
echo _SERVER["SCRIPT_NAME"]; | ||
} | ||
public function f2() -> void | ||
{ | ||
echo _SERVER["SCRIPT_NAME"]; | ||
} | ||
|
||
public function check() { | ||
return _SERVER["HTTP_USER_AGENT"]; | ||
} | ||
/** | ||
* @see https://github.com/phalcon/zephir/issues/1970 | ||
*/ | ||
public function check() -> var | ||
{ | ||
return _SERVER["HTTP_USER_AGENT"]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Zephir. | ||
* | ||
* (c) Zephir Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Extension\Globals; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Test\Globals\Server; | ||
|
||
class ServerTest extends TestCase | ||
{ | ||
private $server; | ||
|
||
/** | ||
* This method is called before each test. | ||
*/ | ||
protected function setUp() | ||
{ | ||
$this->server = $_SERVER; | ||
} | ||
|
||
/** | ||
* This method is called after each test. | ||
*/ | ||
protected function tearDown() | ||
{ | ||
$_SERVER = $this->server; | ||
} | ||
|
||
/** | ||
* @test | ||
* @see https://github.com/phalcon/zephir/issues/1961 | ||
*/ | ||
public function shouldPrintPhpSelf() | ||
{ | ||
$test = new Server(); | ||
|
||
ob_start(); | ||
$test->f1(); | ||
$actual = ob_get_contents(); | ||
ob_end_clean(); | ||
|
||
$this->assertSame(str_repeat($_SERVER['PHP_SELF'], 3), $actual); | ||
} | ||
|
||
/** | ||
* @test | ||
* @see https://github.com/phalcon/zephir/issues/1961 | ||
*/ | ||
public function shouldPrintUserAgent() | ||
{ | ||
$test = new Server(); | ||
$_SERVER['HTTP_USER_AGENT'] = 'Test'; | ||
|
||
$this->assertSame('Test', $test->check()); | ||
} | ||
} |