Skip to content

Commit

Permalink
Some test for require
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurigag committed Mar 26, 2017
1 parent 807d62b commit abbd8ae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/requires.zep
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Test;

class Requires
{
protected someVariable;

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

public function requireExternal3(var path)
{
this->someVariable = "test";
require path;
}
}
13 changes: 12 additions & 1 deletion unit-tests/Extension/RequiresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,23 @@

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();
ob_start();
$r->requireExternal3(__DIR__ . '/php/require-me-3.php');
$output = ob_get_clean();
$this->assertSame("test", $output);
}
}
2 changes: 2 additions & 0 deletions unit-tests/Extension/php/require-me-3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo $this->someVariable;

0 comments on commit abbd8ae

Please sign in to comment.