InfoCheckerTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @author Morris Jobke <hey@morrisjobke.de>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace Test\App\CodeChecker;
  22. use OC\App\CodeChecker\InfoChecker;
  23. use OC\App\InfoParser;
  24. use Test\TestCase;
  25. class InfoCheckerTest extends TestCase {
  26. /** @var InfoChecker */
  27. protected $infoChecker;
  28. public static function setUpBeforeClass() {
  29. \OC::$APPSROOTS[] = [
  30. 'path' => \OC::$SERVERROOT . '/tests/apps',
  31. 'url' => '/apps-test',
  32. 'writable' => false,
  33. ];
  34. }
  35. public static function tearDownAfterClass() {
  36. // remove last element
  37. array_pop(\OC::$APPSROOTS);
  38. }
  39. protected function setUp() {
  40. parent::setUp();
  41. $this->infoChecker = new InfoChecker(new InfoParser());
  42. }
  43. public function appInfoData() {
  44. return [
  45. ['testapp-infoxml', []],
  46. ['testapp-version', []],
  47. ['testapp-infoxml-version', []],
  48. ['testapp-infoxml-version-different', [['type' => 'differentVersions', 'message' => 'appinfo/version: 1.2.4 - appinfo/info.xml: 1.2.3']]],
  49. ['testapp-version-missing', []],
  50. ['testapp-name-missing', [['type' => 'mandatoryFieldMissing', 'field' => 'name']]],
  51. ];
  52. }
  53. /**
  54. * @dataProvider appInfoData
  55. *
  56. * @param $appId
  57. * @param $expectedErrors
  58. */
  59. public function testApps($appId, $expectedErrors) {
  60. $errors = $this->infoChecker->analyse($appId);
  61. $this->assertEquals($expectedErrors, $errors);
  62. }
  63. }