1
0

BootContextTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace lib\AppFramework\Bootstrap;
  8. use OC\AppFramework\Bootstrap\BootContext;
  9. use OCP\AppFramework\IAppContainer;
  10. use OCP\IServerContainer;
  11. use PHPUnit\Framework\MockObject\MockObject;
  12. use Test\TestCase;
  13. class BootContextTest extends TestCase {
  14. /** @var IAppContainer|MockObject */
  15. private $appContainer;
  16. /** @var BootContext */
  17. private $context;
  18. protected function setUp(): void {
  19. parent::setUp();
  20. $this->appContainer = $this->createMock(IAppContainer::class);
  21. $this->context = new BootContext(
  22. $this->appContainer
  23. );
  24. }
  25. public function testGetAppContainer(): void {
  26. $container = $this->context->getAppContainer();
  27. $this->assertSame($this->appContainer, $container);
  28. }
  29. public function testGetServerContainer(): void {
  30. $serverContainer = $this->createMock(IServerContainer::class);
  31. $this->appContainer->method('get')
  32. ->with(IServerContainer::class)
  33. ->willReturn($serverContainer);
  34. $container = $this->context->getServerContainer();
  35. $this->assertSame($serverContainer, $container);
  36. }
  37. }