Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some test for require #1428

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/requires.zep
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

namespace Test;

use Test\Requires\External3;

class Requires
{
protected content;

public function requireExternal1(var path)
{
Expand All @@ -15,4 +18,20 @@ class Requires
return true;
}

public function requireExternal3(var path)
{
var external3;

if PHP_MAJOR_VERSION == 5 {
create_symbol_table();
}
let external3 = new External3();
external3->req(path, this);
return this->content;
}

public function setContent(var content)
{
let this->content = content;
}
}
18 changes: 18 additions & 0 deletions test/requires/External3.zep
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

/**
* External3 operations
*/

namespace Test\Requires;

class External3
{
protected someVariable;

public function req(var path, var requires)
{
ob_clean();
require path;
requires->setContent(ob_get_contents());
}
}
11 changes: 10 additions & 1 deletion unit-tests/Extension/RequiresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@

namespace Extension;

use Test\Requires;

class RequiresTest extends \PHPUnit_Framework_TestCase
{
public function testRequireExternal1()
{
$r = new \Test\Requires();
$r = new Requires();
$this->assertSame($r->requireExternal1(__DIR__ . '/php/require-me-1.php'), array(1, 2, 3));
$this->assertTrue($r->requireExternal1(__DIR__ . '/php/require-me-2.php') && defined('REQUIRE_ME'));
}

public function testRequireExternal3()
{
$r = new Requires();
$output = $r->requireExternal3(__DIR__ . '/php/require-me-3.php');
$this->assertSame("test", $output);
}
}
3 changes: 3 additions & 0 deletions unit-tests/Extension/php/require-me-3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
$this->someVariable["test"] = "test";
echo $this->someVariable["test"];