diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index ab9835dda..f2f572678 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -1,4 +1,5 @@ <?php +Codeception\Util\Autoload::addNamespace('', codecept_root_dir().'/tests/unit'); define('PARAMS_GENERATOR', realpath(codecept_root_dir()."/lib/config.php")); diff --git a/tests/unit/e107/Shims/InternalAlternateTest.php b/tests/unit/e107/Shims/InternalAlternateTest.php new file mode 100644 index 000000000..dd41b7a40 --- /dev/null +++ b/tests/unit/e107/Shims/InternalAlternateTest.php @@ -0,0 +1,31 @@ +<?php +/** + * e107 website system + * + * Copyright (C) 2008-2018 e107 Inc (e107.org) + * Released under the terms and conditions of the + * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) + * + */ + +namespace e107\Shims; + +function readfile($filename, $use_include_path = FALSE, $context = NULL) +{ + foreach(debug_backtrace(false) as $line) + { + if ($line['class'] == InternalAlternateTest::class) + { + return null; + } + } + return @\readfile($filename, $use_include_path, $context); +} + +class InternalAlternateTest extends eShimsTest +{ + public function testReadfile() + { + $this->testReadfileImplementation(array(InternalShims::class, 'readfile')); + } +} diff --git a/tests/unit/e107/Shims/eShimsTest.php b/tests/unit/e107/Shims/eShimsTest.php index 4b91c5bec..50970f060 100644 --- a/tests/unit/e107/Shims/eShimsTest.php +++ b/tests/unit/e107/Shims/eShimsTest.php @@ -8,19 +8,21 @@ * */ +namespace e107\Shims; + class eShimsTest extends \Codeception\Test\Unit { public function testReadfile() { - $this->testReadfileImplementation(array(eShims::class, 'readfile')); + $this->testReadfileImplementation(array(\eShims::class, 'readfile')); } public function testReadfileAlt() { - $this->testReadfileImplementation(array(eShims::class, 'readfile_alt')); + $this->testReadfileImplementation(array(\eShims::class, 'readfile_alt')); } - private function testReadfileImplementation($implementation) + protected function testReadfileImplementation($implementation) { $tmp_handle = tmpfile(); $tmp_filename = stream_get_meta_data($tmp_handle)['uri'];