mirror of
https://github.com/e107inc/e107.git
synced 2025-08-27 00:05:46 +02:00
Performance of e_file_inspector_sqlphar::pathToDefaultPath()
Optimized performance of e_file_inspector_sqlphar::pathToDefaultPath() by eliminating expensive method calls
This commit is contained in:
@@ -62,4 +62,28 @@ class e_file_inspectorTest extends \Codeception\Test\Unit
|
||||
$result = $this->e_integrity->validate("file/does/not/exist.php");
|
||||
$this->assertEquals(0, $result & e_file_inspector::VALIDATED_PRESENCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Create a stable interface for pathToDefaultPath()
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testPathToDefaultPath()
|
||||
{
|
||||
$object = new e_file_inspector_sqlphar();
|
||||
$class = new ReflectionClass(get_class($object));
|
||||
$method = $class->getMethod('pathToDefaultPath');
|
||||
$method->setAccessible(true);
|
||||
$method->invoke($object, 'populate_cache');
|
||||
$member = $class->getProperty('customDirsCache');
|
||||
$member->setAccessible(true);
|
||||
$customDirs = $member->getValue($object);
|
||||
$customDirs['ADMIN_DIRECTORY'] = 'e963_admin/';
|
||||
$member->setValue($object, $customDirs);
|
||||
|
||||
$input = "e963_admin/index.php";
|
||||
$expected = "e107_admin/index.php";
|
||||
$actual = $method->invoke($object, $input);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user