aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/tests/Unit/Controller/PredefinedStatusControllerTest.php
blob: 5709cdc89cf486e2b8f935b96f37485302082174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\UserStatus\Tests\Controller;

use OCA\UserStatus\Controller\PredefinedStatusController;
use OCA\UserStatus\Service\PredefinedStatusService;
use OCP\IRequest;
use Test\TestCase;

class PredefinedStatusControllerTest extends TestCase {

	/** @var PredefinedStatusService|\PHPUnit\Framework\MockObject\MockObject */
	private $service;

	/** @var PredefinedStatusController */
	private $controller;

	protected function setUp(): void {
		parent::setUp();

		$request = $this->createMock(IRequest::class);
		$this->service = $this->createMock(PredefinedStatusService::class);

		$this->controller = new PredefinedStatusController('user_status', $request,
			$this->service);
	}

	public function testFindAll(): void {
		$this->service->expects($this->once())
			->method('getDefaultStatuses')
			->with()
			->willReturn([
				[
					'id' => 'predefined-status-one',
				],
				[
					'id' => 'predefined-status-two',
				],
			]);

		$actual = $this->controller->findAll();
		$this->assertEquals([
			[
				'id' => 'predefined-status-one',
			],
			[
				'id' => 'predefined-status-two',
			],
		], $actual->getData());
	}
}