BundleFetcherTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  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
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. namespace Test\App\AppStore\Bundles;
  22. use OC\App\AppStore\Bundles\BundleFetcher;
  23. use OC\App\AppStore\Bundles\EducationBundle;
  24. use OC\App\AppStore\Bundles\EnterpriseBundle;
  25. use OC\App\AppStore\Bundles\GroupwareBundle;
  26. use OC\App\AppStore\Bundles\HubBundle;
  27. use OC\App\AppStore\Bundles\SocialSharingBundle;
  28. use OCP\IL10N;
  29. use Test\TestCase;
  30. class BundleFetcherTest extends TestCase {
  31. /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
  32. private $l10n;
  33. /** @var BundleFetcher */
  34. private $bundleFetcher;
  35. protected function setUp(): void {
  36. parent::setUp();
  37. $this->l10n = $this->createMock(IL10N::class);
  38. $this->bundleFetcher = new BundleFetcher(
  39. $this->l10n
  40. );
  41. }
  42. public function testGetBundles() {
  43. $expected = [
  44. new EnterpriseBundle($this->l10n),
  45. new HubBundle($this->l10n),
  46. new GroupwareBundle($this->l10n),
  47. new SocialSharingBundle($this->l10n),
  48. new EducationBundle($this->l10n),
  49. ];
  50. $this->assertEquals($expected, $this->bundleFetcher->getBundles());
  51. }
  52. public function testGetBundleByIdentifier() {
  53. $this->assertEquals(new EnterpriseBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('EnterpriseBundle'));
  54. $this->assertEquals(new GroupwareBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('GroupwareBundle'));
  55. }
  56. public function testGetBundleByIdentifierWithException() {
  57. $this->expectException(\BadMethodCallException::class);
  58. $this->expectExceptionMessage('Bundle with specified identifier does not exist');
  59. $this->bundleFetcher->getBundleByIdentifier('NotExistingBundle');
  60. }
  61. }