BundleFetcherTest.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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\PublicSectorBundle;
  28. use OC\App\AppStore\Bundles\SocialSharingBundle;
  29. use OCP\IL10N;
  30. use Test\TestCase;
  31. class BundleFetcherTest extends TestCase {
  32. /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
  33. private $l10n;
  34. /** @var BundleFetcher */
  35. private $bundleFetcher;
  36. protected function setUp(): void {
  37. parent::setUp();
  38. $this->l10n = $this->createMock(IL10N::class);
  39. $this->bundleFetcher = new BundleFetcher(
  40. $this->l10n
  41. );
  42. }
  43. public function testGetBundles() {
  44. $expected = [
  45. new EnterpriseBundle($this->l10n),
  46. new HubBundle($this->l10n),
  47. new GroupwareBundle($this->l10n),
  48. new SocialSharingBundle($this->l10n),
  49. new EducationBundle($this->l10n),
  50. new PublicSectorBundle($this->l10n),
  51. ];
  52. $this->assertEquals($expected, $this->bundleFetcher->getBundles());
  53. }
  54. public function testGetBundleByIdentifier() {
  55. $this->assertEquals(new EnterpriseBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('EnterpriseBundle'));
  56. $this->assertEquals(new GroupwareBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('GroupwareBundle'));
  57. }
  58. public function testGetBundleByIdentifierWithException() {
  59. $this->expectException(\BadMethodCallException::class);
  60. $this->expectExceptionMessage('Bundle with specified identifier does not exist');
  61. $this->bundleFetcher->getBundleByIdentifier('NotExistingBundle');
  62. }
  63. }