Exemplo n.º 1
0
 /**
  * @covers common\classes\AutoLoader::is_extension_changed
  */
 public function test_is_extension_changed()
 {
     $method = new ReflectionMethod(AutoLoader::class, 'is_extension_changed');
     $method->setAccessible(true);
     self::assertFalse($method->invoke(null, 'tools'));
     $test_file = ROOT_PATH . DS . 'build' . DS . 'tools' . DS . 'test.php';
     if (file_exists('pfmextension://tools' . DS . 'test.php')) {
         unlink('pfmextension://tools' . DS . 'test.php');
     }
     file_put_contents($test_file, '');
     self::assertTrue($method->invoke(null, 'tools'));
     unlink($test_file);
     self::assertFalse($method->invoke(null, 'tools'));
     $tools_file = ROOT_PATH . DS . 'build' . DS . 'tools' . DS . 'tools.php';
     $old_data = file_get_contents($tools_file);
     file_put_contents($tools_file, '/*test comment*/', FILE_APPEND);
     self::assertTrue($method->invoke(null, 'tools'));
     file_put_contents($tools_file, $old_data);
     self::assertFalse($method->invoke(null, 'tools'));
     $extension_file = ROOT_PATH . DS . 'extensions' . DS . 'tools.tar.gz';
     Phar::unlinkArchive($extension_file);
     self::assertFalse($method->invoke(null, 'tools'));
     self::assertTrue(AutoLoader::load_extension('Tools'));
 }