BundleFetcherTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace Test\App\AppStore\Bundles;
  7. use OC\App\AppStore\Bundles\BundleFetcher;
  8. use OC\App\AppStore\Bundles\EducationBundle;
  9. use OC\App\AppStore\Bundles\EnterpriseBundle;
  10. use OC\App\AppStore\Bundles\GroupwareBundle;
  11. use OC\App\AppStore\Bundles\HubBundle;
  12. use OC\App\AppStore\Bundles\PublicSectorBundle;
  13. use OC\App\AppStore\Bundles\SocialSharingBundle;
  14. use OCP\IL10N;
  15. use Test\TestCase;
  16. class BundleFetcherTest extends TestCase {
  17. /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
  18. private $l10n;
  19. /** @var BundleFetcher */
  20. private $bundleFetcher;
  21. protected function setUp(): void {
  22. parent::setUp();
  23. $this->l10n = $this->createMock(IL10N::class);
  24. $this->bundleFetcher = new BundleFetcher(
  25. $this->l10n
  26. );
  27. }
  28. public function testGetBundles(): void {
  29. $expected = [
  30. new EnterpriseBundle($this->l10n),
  31. new HubBundle($this->l10n),
  32. new GroupwareBundle($this->l10n),
  33. new SocialSharingBundle($this->l10n),
  34. new EducationBundle($this->l10n),
  35. new PublicSectorBundle($this->l10n),
  36. ];
  37. $this->assertEquals($expected, $this->bundleFetcher->getBundles());
  38. }
  39. public function testGetBundleByIdentifier(): void {
  40. $this->assertEquals(new EnterpriseBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('EnterpriseBundle'));
  41. $this->assertEquals(new GroupwareBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('GroupwareBundle'));
  42. }
  43. public function testGetBundleByIdentifierWithException(): void {
  44. $this->expectException(\BadMethodCallException::class);
  45. $this->expectExceptionMessage('Bundle with specified identifier does not exist');
  46. $this->bundleFetcher->getBundleByIdentifier('NotExistingBundle');
  47. }
  48. }