TrackManiaControl/phpunittests/core/Update/PluginUpdateManagerTest.php

45 lines
1.3 KiB
PHP
Raw Normal View History

2017-04-15 23:20:36 +02:00
<?php
namespace Tests\core\Update;
use ManiaControl\ManiaControl;
use ManiaControl\Utils\WebReader;
2017-04-16 14:43:13 +02:00
/**
* PHP Unit Test for Plugin Update Manager Class
*
* @author ManiaControl Team <mail@maniacontrol.com>
2018-03-27 20:11:40 +02:00
* @copyright 2014-2018 ManiaControl Team
2017-04-16 14:43:13 +02:00
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
2017-04-15 23:20:36 +02:00
class PluginUpdateManagerTest extends \PHPUnit_Framework_TestCase {
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();
//No Plugins Running so No new Updates
$this->assertFalse($pluginUpdateManager->getPluginsUpdates());
2017-04-16 14:43:13 +02:00
$maniaControl->run(10);
2017-04-15 23:20:36 +02:00
2017-04-16 14:43:13 +02:00
//$this->assertNotFalse($pluginUpdateManager->getPluginsUpdates()); //failed manchmal
2017-04-15 23:20:36 +02:00
//TODO load Plugin manually and then test (could happen that no update is existing)
}
2017-04-16 14:43:13 +02:00
2017-04-15 23:20:36 +02:00
}