Added some Unit Tests
This commit is contained in:
		| @@ -9,20 +9,33 @@ | |||||||
| namespace Tests\core\Update; | namespace Tests\core\Update; | ||||||
|  |  | ||||||
| use ManiaControl\ManiaControl; | use ManiaControl\ManiaControl; | ||||||
| use ManiaControl\Update\PluginUpdateManager; |  | ||||||
| use ManiaControl\Utils\WebReader; | use ManiaControl\Utils\WebReader; | ||||||
|  |  | ||||||
| class PluginUpdateManagerTest extends \PHPUnit_Framework_TestCase { | class PluginUpdateManagerTest extends \PHPUnit_Framework_TestCase { | ||||||
| 	public function testGetPluginUpdates(){ | 	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(); | 		$maniaControl        = new ManiaControl(); | ||||||
| 		$updateManager       = $maniaControl->getUpdateManager(); | 		$updateManager       = $maniaControl->getUpdateManager(); | ||||||
| 		$pluginUpdateManager = $updateManager->getPluginUpdateManager(); | 		$pluginUpdateManager = $updateManager->getPluginUpdateManager(); | ||||||
|  |  | ||||||
| 		var_dump($pluginUpdateManager->getPluginsUpdates()); | 		//No Plugins Running so No new Updates | ||||||
|  | 		$this->assertFalse($pluginUpdateManager->getPluginsUpdates()); | ||||||
|  |  | ||||||
| 		$url        = ManiaControl::URL_WEBSERVICE . 'plugins'; | 		$maniaControl->run(5); | ||||||
| 		$response   = WebReader::getUrl($url); |  | ||||||
| 		$dataJson   = $response->getContent(); | 		$this->assertNotFalse($pluginUpdateManager->getPluginsUpdates()); | ||||||
| 		var_dump($dataJson); | 		//TODO load Plugin manually and then test (could happen that no update is existing) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user