InfoCheckerTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. }