1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 11:20:25 +02:00

Blank out core_image.php in repo

This file is basically always going to be outdated in the development
tree. Use the build artifact files for integrity verification.

Tests have also been modified not to use this file.
This commit is contained in:
Nick Liu
2020-04-29 11:00:00 -05:00
parent 7291ebc8b1
commit 01404fa9c6
2 changed files with 42 additions and 20 deletions

Binary file not shown.

View File

@@ -10,15 +10,35 @@
class e_file_inspectorTest extends \Codeception\Test\Unit
{
/**
* @var e_file_inspector_sqlphar
* @var e_file_inspector
*/
private $e_integrity;
const TEST_INTEGRITY_CONTENTS = [
'index.php' => [
'v1.0.0' => 'd41d8cd98f00b204e9800998ecf8427e'
],
'e107_admin' => [
'e107_update.php' => [
'v1.0.0' => 'd41d8cd98f00b204e9800998ecf8427e'
]
],
'e107_themes' => [
'index.html' => [
'v1.0.0' => 'd41d8cd98f00b204e9800998ecf8427e'
]
]
];
public function _before()
{
require_once(e_HANDLER . "e_file_inspector_json_phar.php");
// TODO: Make test databases; don't hard-code e107_admin/core_image.php and hope it has the expected content.
$this->e_integrity = new e_file_inspector_json_phar(e_ADMIN . "core_image.php");
$tmpfile = tmpfile();
$tmpfilePath = stream_get_meta_data($tmpfile)['uri'];
$testIntegrityImage = '<?php $core_image = ' .
var_export(json_encode(self::TEST_INTEGRITY_CONTENTS), true) .
';';
file_put_contents($tmpfilePath, $testIntegrityImage);
require_once(e_HANDLER . "e_file_inspector_json.php");
$this->e_integrity = new e_file_inspector_json($tmpfilePath);
$this->e_integrity->loadDatabase();
}
@@ -52,7 +72,7 @@ class e_file_inspectorTest extends \Codeception\Test\Unit
public function testValidate()
{
$result = $this->e_integrity->validate("index.php");
$result = $this->e_integrity->validate("e107_themes/index.html");
$this->assertGreaterThanOrEqual(1, $result & e_file_inspector::VALIDATED);
$this->assertGreaterThanOrEqual(1, $result & e_file_inspector::VALIDATED_PATH_KNOWN);
$this->assertGreaterThanOrEqual(1, $result & e_file_inspector::VALIDATED_PATH_VERSION);
@@ -68,15 +88,7 @@ class e_file_inspectorTest extends \Codeception\Test\Unit
public function testCustomPathToDefaultPath()
{
/** @var e_file_inspector $object */
$object = $this->make('e_file_inspector');
$class = new ReflectionClass(get_class($object));
$object->customPathToDefaultPath('populate_cache');
$member = $class->getProperty('customDirsCache');
$member->setAccessible(true);
$customDirs = $member->getValue($object);
$customDirs['ADMIN_DIRECTORY'] = 'e963_admin/';
$member->setValue($object, $customDirs);
$object = $this->createCustomPathFileInspector();
$input = "e963_admin/index.php";
$expected = "e107_admin/index.php";
@@ -86,6 +98,21 @@ class e_file_inspectorTest extends \Codeception\Test\Unit
}
public function testDefaultPathToCustomPath()
{
$object = $this->createCustomPathFileInspector();
$input = "e107_admin/index.php";
$expected = "e963_admin/index.php";
$actual = $object->defaultPathToCustomPath($input);
$this->assertEquals($expected, $actual);
}
/**
* @return e_file_inspector
* @throws ReflectionException if e_file_inspector is broken
*/
private function createCustomPathFileInspector()
{
/** @var e_file_inspector $object */
$object = $this->make('e_file_inspector');
@@ -96,11 +123,6 @@ class e_file_inspectorTest extends \Codeception\Test\Unit
$customDirs = $member->getValue($object);
$customDirs['ADMIN_DIRECTORY'] = 'e963_admin/';
$member->setValue($object, $customDirs);
$input = "e107_admin/index.php";
$expected = "e963_admin/index.php";
$actual = $object->defaultPathToCustomPath($input);
$this->assertEquals($expected, $actual);
return $object;
}
}