UserStatusWidgetTest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2020, Georg Ehrke
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Georg Ehrke <oc.list@georgehrke.com>
  8. * @author Richard Steinmetz <richard@steinmetz.cloud>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\UserStatus\Tests\Dashboard;
  27. use OCA\UserStatus\Dashboard\UserStatusWidget;
  28. use OCA\UserStatus\Service\StatusService;
  29. use OCP\AppFramework\Services\IInitialState;
  30. use OCP\IDateTimeFormatter;
  31. use OCP\IL10N;
  32. use OCP\IURLGenerator;
  33. use OCP\IUserManager;
  34. use OCP\IUserSession;
  35. use Test\TestCase;
  36. class UserStatusWidgetTest extends TestCase {
  37. /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
  38. private $l10n;
  39. /** @var IDateTimeFormatter|\PHPUnit\Framework\MockObject\MockObject */
  40. private $dateTimeFormatter;
  41. /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */
  42. private $urlGenerator;
  43. /** @var IInitialState|\PHPUnit\Framework\MockObject\MockObject */
  44. private $initialState;
  45. /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
  46. private $userManager;
  47. /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
  48. private $userSession;
  49. /** @var StatusService|\PHPUnit\Framework\MockObject\MockObject */
  50. private $service;
  51. /** @var UserStatusWidget */
  52. private $widget;
  53. protected function setUp(): void {
  54. parent::setUp();
  55. $this->l10n = $this->createMock(IL10N::class);
  56. $this->dateTimeFormatter = $this->createMock(IDateTimeFormatter::class);
  57. $this->urlGenerator = $this->createMock(IURLGenerator::class);
  58. $this->initialState = $this->createMock(IInitialState::class);
  59. $this->userManager = $this->createMock(IUserManager::class);
  60. $this->userSession = $this->createMock(IUserSession::class);
  61. $this->service = $this->createMock(StatusService::class);
  62. $this->widget = new UserStatusWidget($this->l10n, $this->dateTimeFormatter, $this->urlGenerator, $this->initialState, $this->userManager, $this->userSession, $this->service);
  63. }
  64. public function testGetId(): void {
  65. $this->assertEquals('user_status', $this->widget->getId());
  66. }
  67. public function testGetTitle(): void {
  68. $this->l10n->expects($this->exactly(1))
  69. ->method('t')
  70. ->willReturnArgument(0);
  71. $this->assertEquals('Recent statuses', $this->widget->getTitle());
  72. }
  73. public function testGetOrder(): void {
  74. $this->assertEquals(5, $this->widget->getOrder());
  75. }
  76. public function testGetIconClass(): void {
  77. $this->assertEquals('icon-user-status-dark', $this->widget->getIconClass());
  78. }
  79. public function testGetUrl(): void {
  80. $this->assertNull($this->widget->getUrl());
  81. }
  82. }