diff -u b/core/modules/system/lib/Drupal/system/Tests/PhpLoader/MTimeProtectedLoaderTest.php b/core/modules/system/lib/Drupal/system/Tests/PhpLoader/MTimeProtectedLoaderTest.php --- b/core/modules/system/lib/Drupal/system/Tests/PhpLoader/MTimeProtectedLoaderTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/PhpLoader/MTimeProtectedLoaderTest.php @@ -7,16 +7,14 @@ namespace Drupal\system\Tests\PhpLoader; -use Drupal\simpletest\UnitTestBase; - /** * Tests the directory mtime based PHP loader implementation. */ -class MTimeProtectedLoaderTest extends UnitTestBase { +class MTimeProtectedLoaderTest extends PhpLoaderTestBase { public static function getInfo() { return array( - 'name' => 'Loader test', + 'name' => 'MTime loader', 'description' => 'Tests the protected loader.', 'group' => 'System', ); @@ -31,21 +29,11 @@ */ public function testMTimeProtectedLoader() { - $conf['loader_classes'] = array('default' => + $this->doTest(array('default' => array( 'class' => 'Drupal\Component\PhpLoader\MTimeProtectedLoader', 'prefix' => variable_get('file_public_path', conf_path() . '/files') . '/codegen', 'secret' => $GLOBALS['drupal_hash_salt'], ), - ); - drupal_static_reset('_drupal_php_get_loader'); - $filename = $this->randomName() . '/' . $this->randomName() . '.php'; - do { - $random = mt_rand(10000, 100000); - $function = 'test' . $random; - } while (function_exists($function)); - $contents = "write($filename, $contents); - drupal_php_loader()->includePhp($filename); - $this->assertIdentical($function(), $random); + )); } } only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/PhpLoader/NativeLoaderTest.php @@ -0,0 +1,38 @@ + 'Native loader', + 'description' => 'Tests the native loader.', + 'group' => 'System', + ); + } + + /** + * Tests the directory mtime based PHP loader implementation. + * + * This test first writes a file containing the definition of a non-existing + * function returning a random. Then loads it back, calls the function and + * asserts the return is correct. + */ + public function testNativeLoader() { + $this->doTest(array('default' => + array( + 'class' => 'Drupal\Component\PhpLoader\NativeLoader', + 'prefix' => variable_get('file_public_path', conf_path() . '/files') . '/codegen', + ), + )); + } +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/PhpLoader/PhpLoaderTestBase.php @@ -0,0 +1,37 @@ +randomName() . '/' . $this->randomName() . '.php'; + do { + $random = mt_rand(10000, 100000); + $function = 'test' . $random; + } while (function_exists($function)); + $contents = "write($filename, $contents); + drupal_php_loader()->includePhp($filename); + $this->assertIdentical($function(), $random); + } +}