UserStatusWidgetTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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\Dashboard;
  8. use OCA\UserStatus\Dashboard\UserStatusWidget;
  9. use OCA\UserStatus\Service\StatusService;
  10. use OCP\AppFramework\Services\IInitialState;
  11. use OCP\IDateTimeFormatter;
  12. use OCP\IL10N;
  13. use OCP\IURLGenerator;
  14. use OCP\IUserManager;
  15. use OCP\IUserSession;
  16. use Test\TestCase;
  17. class UserStatusWidgetTest extends TestCase {
  18. /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
  19. private $l10n;
  20. /** @var IDateTimeFormatter|\PHPUnit\Framework\MockObject\MockObject */
  21. private $dateTimeFormatter;
  22. /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
  23. private $urlGenerator;
  24. /** @var IInitialState|\PHPUnit\Framework\MockObject\MockObject */
  25. private $initialState;
  26. /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
  27. private $userManager;
  28. /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
  29. private $userSession;
  30. /** @var StatusService|\PHPUnit\Framework\MockObject\MockObject */
  31. private $service;
  32. /** @var UserStatusWidget */
  33. private $widget;
  34. protected function setUp(): void {
  35. parent::setUp();
  36. $this->l10n = $this->createMock(IL10N::class);
  37. $this->dateTimeFormatter = $this->createMock(IDateTimeFormatter::class);
  38. $this->urlGenerator = $this->createMock(IURLGenerator::class);
  39. $this->initialState = $this->createMock(IInitialState::class);
  40. $this->userManager = $this->createMock(IUserManager::class);
  41. $this->userSession = $this->createMock(IUserSession::class);
  42. $this->service = $this->createMock(StatusService::class);
  43. $this->widget = new UserStatusWidget($this->l10n, $this->dateTimeFormatter, $this->urlGenerator, $this->initialState, $this->userManager, $this->userSession, $this->service);
  44. }
  45. public function testGetId(): void {
  46. $this->assertEquals('user_status', $this->widget->getId());
  47. }
  48. public function testGetTitle(): void {
  49. $this->l10n->expects($this->exactly(1))
  50. ->method('t')
  51. ->willReturnArgument(0);
  52. $this->assertEquals('Recent statuses', $this->widget->getTitle());
  53. }
  54. public function testGetOrder(): void {
  55. $this->assertEquals(5, $this->widget->getOrder());
  56. }
  57. public function testGetIconClass(): void {
  58. $this->assertEquals('icon-user-status-dark', $this->widget->getIconClass());
  59. }
  60. public function testGetUrl(): void {
  61. $this->assertNull($this->widget->getUrl());
  62. }
  63. }