InfoCheckerTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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', [['type' => 'mandatoryFieldMissing', 'field' => 'version']]],
  47. ['testapp-dependency-missing', [
  48. ['type' => 'missingRequirement', 'field' => 'min'],
  49. ['type' => 'missingRequirement', 'field' => 'max'],
  50. ['type' => 'mandatoryFieldMissing', 'field' => 'dependencies'],
  51. ]],
  52. ['testapp-name-missing', [['type' => 'mandatoryFieldMissing', 'field' => 'name']]],
  53. ];
  54. }
  55. /**
  56. * @dataProvider appInfoData
  57. *
  58. * @param $appId
  59. * @param $expectedErrors
  60. */
  61. public function testApps($appId, $expectedErrors) {
  62. $errors = $this->infoChecker->analyse($appId);
  63. $this->assertEquals($expectedErrors, $errors);
  64. }
  65. }