mirror of
https://github.com/e107inc/e107.git
synced 2025-03-24 06:19:57 +01:00
100% test coverage for \e107\Shims
New test forces a failover of the `readfile()` internal function to test the failover functionality of \e107\Shims\Internal::readfile()
This commit is contained in:
parent
7c2b4f8f25
commit
9e0d603609
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
Codeception\Util\Autoload::addNamespace('', codecept_root_dir().'/tests/unit');
|
||||
|
||||
define('PARAMS_GENERATOR', realpath(codecept_root_dir()."/lib/config.php"));
|
||||
|
||||
|
31
tests/unit/e107/Shims/InternalAlternateTest.php
Normal file
31
tests/unit/e107/Shims/InternalAlternateTest.php
Normal file
@ -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'));
|
||||
}
|
||||
}
|
@ -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'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user