PlatformRepositoryTest.php 2.7 KB

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