installer.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Georg Ehrke <georg@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. class Test_Installer extends \Test\TestCase {
  9. private static $appid = 'testapp';
  10. private $appstore;
  11. protected function setUp() {
  12. parent::setUp();
  13. $this->appstore = OC_Config::getValue('appstoreenabled', true);
  14. OC_Config::setValue('appstoreenabled', true);
  15. OC_Installer::removeApp(self::$appid);
  16. }
  17. protected function tearDown() {
  18. OC_Installer::removeApp(self::$appid);
  19. OC_Config::setValue('appstoreenabled', $this->appstore);
  20. parent::tearDown();
  21. }
  22. public function testInstallApp() {
  23. $pathOfTestApp = __DIR__;
  24. $pathOfTestApp .= '/../data/';
  25. $pathOfTestApp .= 'testapp.zip';
  26. $tmp = OC_Helper::tmpFile('.zip');
  27. OC_Helper::copyr($pathOfTestApp, $tmp);
  28. $data = array(
  29. 'path' => $tmp,
  30. 'source' => 'path',
  31. );
  32. OC_Installer::installApp($data);
  33. $isInstalled = OC_Installer::isInstalled(self::$appid);
  34. $this->assertTrue($isInstalled);
  35. }
  36. public function testUpdateApp() {
  37. $pathOfOldTestApp = __DIR__;
  38. $pathOfOldTestApp .= '/../data/';
  39. $pathOfOldTestApp .= 'testapp.zip';
  40. $oldTmp = OC_Helper::tmpFile('.zip');
  41. OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
  42. $oldData = array(
  43. 'path' => $oldTmp,
  44. 'source' => 'path',
  45. );
  46. $pathOfNewTestApp = __DIR__;
  47. $pathOfNewTestApp .= '/../data/';
  48. $pathOfNewTestApp .= 'testapp2.zip';
  49. $newTmp = OC_Helper::tmpFile('.zip');
  50. OC_Helper::copyr($pathOfNewTestApp, $newTmp);
  51. $newData = array(
  52. 'path' => $newTmp,
  53. 'source' => 'path',
  54. );
  55. OC_Installer::installApp($oldData);
  56. $oldVersionNumber = OC_App::getAppVersion(self::$appid);
  57. OC_Installer::updateApp($newData);
  58. $newVersionNumber = OC_App::getAppVersion(self::$appid);
  59. $this->assertNotEquals($oldVersionNumber, $newVersionNumber);
  60. }
  61. }