You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.1 KiB

  1. <?php
  2. /**
  3. * Copyright (c) 2012 Bernhard Posselt <nukeawhale@gmail.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_App extends PHPUnit_Framework_TestCase {
  9. public function testIsAppVersionCompatibleSingleOCNumber(){
  10. $oc = array(4);
  11. $app = '4.0';
  12. $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
  13. }
  14. public function testIsAppVersionCompatibleMultipleOCNumber(){
  15. $oc = array(4, 3, 1);
  16. $app = '4.3';
  17. $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
  18. }
  19. public function testIsAppVersionCompatibleSingleNumber(){
  20. $oc = array(4);
  21. $app = '4';
  22. $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
  23. }
  24. public function testIsAppVersionCompatibleSingleAppNumber(){
  25. $oc = array(4, 3);
  26. $app = '4';
  27. $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
  28. }
  29. public function testIsAppVersionCompatibleComplex(){
  30. $oc = array(5, 0, 0);
  31. $app = '4.5.1';
  32. $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
  33. }
  34. public function testIsAppVersionCompatibleShouldFail(){
  35. $oc = array(4, 3, 1);
  36. $app = '4.3.2';
  37. $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app));
  38. }
  39. public function testIsAppVersionCompatibleShouldFailTwoVersionNumbers(){
  40. $oc = array(4, 3, 1);
  41. $app = '4.4';
  42. $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app));
  43. }
  44. public function testIsAppVersionCompatibleShouldWorkForPreAlpha(){
  45. $oc = array(5, 0, 3);
  46. $app = '4.93';
  47. $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
  48. }
  49. public function testIsAppVersionCompatibleShouldFailOneVersionNumbers(){
  50. $oc = array(4, 3, 1);
  51. $app = '5';
  52. $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app));
  53. }
  54. /**
  55. * Tests that the app order is correct
  56. */
  57. public function testGetEnabledAppsIsSorted() {
  58. $apps = \OC_App::getEnabledApps(true);
  59. // copy array
  60. $sortedApps = $apps;
  61. sort($sortedApps);
  62. // 'files' is always on top
  63. unset($sortedApps[array_search('files', $sortedApps)]);
  64. array_unshift($sortedApps, 'files');
  65. $this->assertEquals($sortedApps, $apps);
  66. }
  67. }