PlatformRepositoryTest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2020-2023 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2014-2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test\App;
  8. use OC;
  9. class PlatformRepositoryTest extends \Test\TestCase {
  10. /**
  11. * @dataProvider providesVersions
  12. * @param $expected
  13. * @param $input
  14. */
  15. public function testVersion($input, $expected) {
  16. $pr = new OC\App\PlatformRepository();
  17. $normalizedVersion = $pr->normalizeVersion($input);
  18. $this->assertEquals($expected, $normalizedVersion);
  19. }
  20. public function providesVersions() {
  21. return [
  22. 'none' => ['1.0.0', '1.0.0.0'],
  23. 'none/2' => ['1.2.3.4', '1.2.3.4'],
  24. 'parses state' => ['1.0.0RC1dev', '1.0.0.0-RC1-dev'],
  25. 'CI parsing' => ['1.0.0-rC15-dev', '1.0.0.0-RC15-dev'],
  26. 'delimiters' => ['1.0.0.RC.15-dev', '1.0.0.0-RC15-dev'],
  27. 'RC uppercase' => ['1.0.0-rc1', '1.0.0.0-RC1'],
  28. 'patch replace' => ['1.0.0.pl3-dev', '1.0.0.0-patch3-dev'],
  29. 'forces w.x.y.z' => ['1.0-dev', '1.0.0.0-dev'],
  30. 'forces w.x.y.z/2' => ['0', '0.0.0.0'],
  31. 'parses long' => ['10.4.13-beta', '10.4.13.0-beta'],
  32. 'parses long/2' => ['10.4.13beta2', '10.4.13.0-beta2'],
  33. 'parses long/semver' => ['10.4.13beta.2', '10.4.13.0-beta2'],
  34. 'expand shorthand' => ['10.4.13-b', '10.4.13.0-beta'],
  35. 'expand shorthand2' => ['10.4.13-b5', '10.4.13.0-beta5'],
  36. 'strips leading v' => ['v1.0.0', '1.0.0.0'],
  37. 'strips v/datetime' => ['v20100102', '20100102'],
  38. 'parses dates y-m' => ['2010.01', '2010-01'],
  39. 'parses dates w/ .' => ['2010.01.02', '2010-01-02'],
  40. 'parses dates w/ -' => ['2010-01-02', '2010-01-02'],
  41. 'parses numbers' => ['2010-01-02.5', '2010-01-02-5'],
  42. 'parses dates y.m.Y' => ['2010.1.555', '2010.1.555.0'],
  43. 'parses datetime' => ['20100102-203040', '20100102-203040'],
  44. 'parses dt+number' => ['20100102203040-10', '20100102203040-10'],
  45. 'parses dt+patch' => ['20100102-203040-p1', '20100102-203040-patch1'],
  46. 'parses master' => ['dev-master', '9999999-dev'],
  47. 'parses trunk' => ['dev-trunk', '9999999-dev'],
  48. // 'parses branches' => array('1.x-dev', '1.9999999.9999999.9999999-dev'),
  49. 'parses arbitrary' => ['dev-feature-foo', 'dev-feature-foo'],
  50. 'parses arbitrary2' => ['DEV-FOOBAR', 'dev-FOOBAR'],
  51. 'parses arbitrary3' => ['dev-feature/foo', 'dev-feature/foo'],
  52. 'ignores aliases' => ['dev-master as 1.0.0', '9999999-dev'],
  53. // 'semver metadata' => array('dev-master+foo.bar', '9999999-dev'),
  54. // 'semver metadata/2' => array('1.0.0-beta.5+foo', '1.0.0.0-beta5'),
  55. // 'semver metadata/3' => array('1.0.0+foo', '1.0.0.0'),
  56. // 'metadata w/ alias' => array('1.0.0+foo as 2.0', '1.0.0.0'),
  57. ];
  58. }
  59. }