PredefinedStatusControllerTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020, Georg Ehrke
  5. *
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\UserStatus\Tests\Controller;
  24. use OCA\UserStatus\Controller\PredefinedStatusController;
  25. use OCA\UserStatus\Service\PredefinedStatusService;
  26. use OCP\IRequest;
  27. use Test\TestCase;
  28. class PredefinedStatusControllerTest extends TestCase {
  29. /** @var PredefinedStatusService|\PHPUnit\Framework\MockObject\MockObject */
  30. private $service;
  31. /** @var PredefinedStatusController */
  32. private $controller;
  33. protected function setUp(): void {
  34. parent::setUp();
  35. $request = $this->createMock(IRequest::class);
  36. $this->service = $this->createMock(PredefinedStatusService::class);
  37. $this->controller = new PredefinedStatusController('user_status', $request,
  38. $this->service);
  39. }
  40. public function testFindAll() {
  41. $this->service->expects($this->once())
  42. ->method('getDefaultStatuses')
  43. ->with()
  44. ->willReturn([
  45. [
  46. 'id' => 'predefined-status-one',
  47. ],
  48. [
  49. 'id' => 'predefined-status-two',
  50. ],
  51. ]);
  52. $actual = $this->controller->findAll();
  53. $this->assertEquals([
  54. [
  55. 'id' => 'predefined-status-one',
  56. ],
  57. [
  58. 'id' => 'predefined-status-two',
  59. ],
  60. ], $actual->getData());
  61. }
  62. }