From 0a0815611e4318b6607693d425cb53d1ed742552 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 15 Apr 2017 23:16:07 +0200 Subject: [PATCH] Added some Unit Tests --- Tests/core/Update/PluginUpdateManagerTest.php | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Tests/core/Update/PluginUpdateManagerTest.php b/Tests/core/Update/PluginUpdateManagerTest.php index 5c03b7c5..73a117dd 100644 --- a/Tests/core/Update/PluginUpdateManagerTest.php +++ b/Tests/core/Update/PluginUpdateManagerTest.php @@ -9,20 +9,33 @@ namespace Tests\core\Update; use ManiaControl\ManiaControl; -use ManiaControl\Update\PluginUpdateManager; use ManiaControl\Utils\WebReader; class PluginUpdateManagerTest extends \PHPUnit_Framework_TestCase { - public function testGetPluginUpdates(){ - $maniaControl = new ManiaControl(); - $updateManager = $maniaControl->getUpdateManager(); + public function testWebReaderAndPluginsWebservice() { + $url = ManiaControl::URL_WEBSERVICE . 'plugins'; + $response = WebReader::getUrl($url); + $dataJson = $response->getContent(); + + $this->assertJson($dataJson); + + $data = json_decode($dataJson); + + $this->assertEquals(8, $data[0]->id); + $this->assertEquals("https://download.maniacontrol.com/plugins/8_Dedimania_Plugin_v0.1.zip", $data[0]->currentVersion->url); + } + + public function testGetPluginUpdates() { + $maniaControl = new ManiaControl(); + $updateManager = $maniaControl->getUpdateManager(); $pluginUpdateManager = $updateManager->getPluginUpdateManager(); - var_dump($pluginUpdateManager->getPluginsUpdates()); + //No Plugins Running so No new Updates + $this->assertFalse($pluginUpdateManager->getPluginsUpdates()); - $url = ManiaControl::URL_WEBSERVICE . 'plugins'; - $response = WebReader::getUrl($url); - $dataJson = $response->getContent(); - var_dump($dataJson); + $maniaControl->run(5); + + $this->assertNotFalse($pluginUpdateManager->getPluginsUpdates()); + //TODO load Plugin manually and then test (could happen that no update is existing) } }