PredefinedStatusControllerTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 OCA\UserStatus\Tests\Controller;
  8. use OCA\UserStatus\Controller\PredefinedStatusController;
  9. use OCA\UserStatus\Service\PredefinedStatusService;
  10. use OCP\IRequest;
  11. use Test\TestCase;
  12. class PredefinedStatusControllerTest extends TestCase {
  13. /** @var PredefinedStatusService|\PHPUnit\Framework\MockObject\MockObject */
  14. private $service;
  15. /** @var PredefinedStatusController */
  16. private $controller;
  17. protected function setUp(): void {
  18. parent::setUp();
  19. $request = $this->createMock(IRequest::class);
  20. $this->service = $this->createMock(PredefinedStatusService::class);
  21. $this->controller = new PredefinedStatusController('user_status', $request,
  22. $this->service);
  23. }
  24. public function testFindAll(): void {
  25. $this->service->expects($this->once())
  26. ->method('getDefaultStatuses')
  27. ->with()
  28. ->willReturn([
  29. [
  30. 'id' => 'predefined-status-one',
  31. ],
  32. [
  33. 'id' => 'predefined-status-two',
  34. ],
  35. ]);
  36. $actual = $this->controller->findAll();
  37. $this->assertEquals([
  38. [
  39. 'id' => 'predefined-status-one',
  40. ],
  41. [
  42. 'id' => 'predefined-status-two',
  43. ],
  44. ], $actual->getData());
  45. }
  46. }