BundleFetcherTest.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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\CoreBundle;
  24. use OC\App\AppStore\Bundles\EducationBundle;
  25. use OC\App\AppStore\Bundles\EnterpriseBundle;
  26. use OC\App\AppStore\Bundles\GroupwareBundle;
  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. public function setUp() {
  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 GroupwareBundle($this->l10n),
  46. new SocialSharingBundle($this->l10n),
  47. new EducationBundle($this->l10n),
  48. ];
  49. $this->assertEquals($expected, $this->bundleFetcher->getBundles());
  50. }
  51. public function testGetDefaultInstallationBundle() {
  52. $expected = [
  53. new CoreBundle($this->l10n),
  54. ];
  55. $this->assertEquals($expected, $this->bundleFetcher->getDefaultInstallationBundle());
  56. }
  57. public function testGetBundleByIdentifier() {
  58. $this->assertEquals(new EnterpriseBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('EnterpriseBundle'));
  59. $this->assertEquals(new CoreBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('CoreBundle'));
  60. $this->assertEquals(new GroupwareBundle($this->l10n), $this->bundleFetcher->getBundleByIdentifier('GroupwareBundle'));
  61. }
  62. /**
  63. * @expectedException \BadMethodCallException
  64. * @expectedExceptionMessage Bundle with specified identifier does not exist
  65. */
  66. public function testGetBundleByIdentifierWithException() {
  67. $this->bundleFetcher->getBundleByIdentifier('NotExistingBundle');
  68. }
  69. }