From 556aea02ea0d5d848ebbd2761adeeb89c6a9c4c2 Mon Sep 17 00:00:00 2001 From: Nick Liu Date: Thu, 1 Nov 2018 19:11:15 -0500 Subject: [PATCH] Removed Internet dependency from pluginsTest::testRemotePlugin() --- tests/unit/pluginsTest.php | 843 ++++++++++++++++++++++++++++++++++++- 1 file changed, 836 insertions(+), 7 deletions(-) diff --git a/tests/unit/pluginsTest.php b/tests/unit/pluginsTest.php index 1fb753463..347c69c14 100644 --- a/tests/unit/pluginsTest.php +++ b/tests/unit/pluginsTest.php @@ -324,17 +324,32 @@ public function testRemotePlugin() { require_once(e_HANDLER."e_marketplace.php"); - $mp = new e_marketplace; + try + { + $mock_adapter = $this->make('e_marketplace_adapter_wsdl', + [ + 'getRemoteFile' => function($remote_url, $local_file, $type='temp') + { + file_put_contents(e_TEMP.$local_file, self::samplePluginContents()); + return true; + } + ]); + $mp = $this->make('e_marketplace', + [ + 'adapter' => $mock_adapter + ]); + } + catch (Exception $e) + { + $this->fail("Couldn't load e_marketplace object"); + } + $mp->__construct(); $id = 912; // No-follow plugin on e107.org - $status = $mp->download($id, '', 'plugin'); - // $messages = e107::getMessage()->render('default',false,true,true); + $this->assertFalse(is_dir(e_PLUGIN."nofollow"), "Plugin nofollow exists before download"); - // print_r($messages); - // var_dump($status); - - // $this->assertTrue($status, "Couldn't download/move remote plugin"); + $mp->download($id, '', 'plugin'); $this->pluginInstall('nofollow'); @@ -438,4 +453,818 @@ return $plugin_addon_names; } + + private static function samplePluginContents() + { + return base64_decode(<<