/** * @access * @author "Lionel Lecaque, <*****@*****.**>" */ public function testDownloadRelease() { $this->service->setReleaseManifestUrl(BASE_URL . '/test/sample/releases10.xml'); $updateSites = $this->service->getUpdateSites(); //replace fake url with the one that will work for test case $updateSite = str_replace('$BASE_URL', BASE_URL, $updateSites['default']); $updateSites['default'] = $updateSite; $availableUpdates = $this->service->getAvailableUpdates(); $releaseFile = $availableUpdates['10.10.99']['file']; $localFolder = dirname(__FILE__) . '/download/'; $tmpFolder = dirname(__FILE__) . '/tmp/'; try { $dlPath = $this->service->downloadRelease($releaseFile, $updateSites['default'], $localFolder); $this->assertTrue(is_file($dlPath)); $zip = new ZipArchive(); $zip->open($dlPath); $zip->extractTo($tmpFolder); $this->assertFalse($zip->locateName('TAO_10.10.99_build/version') === false); $this->assertTrue(is_file($tmpFolder . 'TAO_10.10.99_build/version')); $versionFileContent = @file_get_contents($tmpFolder . 'TAO_10.10.99_build/version'); $this->assertEqual($versionFileContent, '10.10.99'); } catch (taoUpdate_models_classes_UpdateException $e) { $this->fail('Exception raised ' . $e->getMessage()); } try { $dlPath = $this->service->downloadRelease('10.10.98', $updateSites['default'], $localFolder); } catch (Exception $e) { $this->assertIsA($e, 'taoUpdate_models_classes_UpdateException'); } try { $dlPath = $this->service->downloadRelease('10.10.99', 'http://localhost/badlnk', $localFolder); } catch (Exception $e) { $this->assertIsA($e, 'taoUpdate_models_classes_UpdateException'); } try { helpers_File::remove($localFolder . $releaseFile); helpers_File::remove($tmpFolder . 'TAO_10.10.99_build/version'); } catch (common_Exception $e) { $this->fail('Exception raised ' . $e->getMessage()); } }