Browse Source

Fix unit tests

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/2858/head
Joas Schilling 6 years ago
parent
commit
0405c64b6d
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 43
      tests/php/Chat/NotifierTest.php
  2. 12
      tests/php/Controller/RoomControllerTest.php

43
tests/php/Chat/NotifierTest.php

@ -30,25 +30,27 @@ use OCA\Talk\Manager;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\Comments\IComment;
use OCP\IConfig;
use OCP\Notification\IManager as INotificationManager;
use OCP\Notification\INotification;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class NotifierTest extends \Test\TestCase {
class NotifierTest extends TestCase {
/** @var \OCP\Notification\IManager|\PHPUnit_Framework_MockObject_MockObject */
/** @var INotificationManager|MockObject */
protected $notificationManager;
/** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */
/** @var IUserManager|MockObject */
protected $userManager;
/** @var \OCA\Talk\Manager|\PHPUnit_Framework_MockObject_MockObject */
/** @var Manager|MockObject */
protected $manager;
/** @var \OCA\Talk\Files\Util|\PHPUnit_Framework_MockObject_MockObject */
/** @var IConfig|MockObject */
protected $config;
/** @var Util|MockObject */
protected $util;
/** @var \OCA\Talk\Chat\Notifier */
/** @var Notifier */
protected $notifier;
public function setUp(): void {
@ -59,22 +61,21 @@ class NotifierTest extends \Test\TestCase {
$this->userManager = $this->createMock(IUserManager::class);
$this->userManager
->method('userExists')
->will($this->returnCallback(function($userId) {
if ($userId === 'unknownUser') {
return false;
}
return true;
}));
->willReturnCallback(function($userId) {
return $userId !== 'unknownUser';
});
$this->manager = $this->createMock(Manager::class);
$this->config = $this->createMock(IConfig::class);
$this->util = $this->createMock(Util::class);
$this->notifier = new Notifier($this->notificationManager,
$this->userManager,
$this->manager,
$this->util);
$this->notifier = new Notifier(
$this->notificationManager,
$this->userManager,
$this->manager,
$this->config,
$this->util
);
}
private function newComment($id, $actorType, $actorId, $creationDateTime, $message) {

12
tests/php/Controller/RoomControllerTest.php

@ -26,8 +26,6 @@ namespace OCA\Talk\Tests\php\Controller;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Chat\MessageParser;
use OCA\Talk\Controller\RoomController;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\GuestManager;
use OCA\Talk\Manager;
use OCA\Talk\Participant;
@ -38,13 +36,15 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class RoomControllerTest extends \Test\TestCase {
class RoomControllerTest extends TestCase {
/** @var string */
private $userId;
@ -70,6 +70,8 @@ class RoomControllerTest extends \Test\TestCase {
protected $timeFactory;
/** @var IL10N|MockObject */
private $l;
/** @var IConfig|MockObject */
private $config;
public function setUp(): void {
@ -87,6 +89,7 @@ class RoomControllerTest extends \Test\TestCase {
$this->messageParser = $this->createMock(MessageParser::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->l = $this->createMock(IL10N::class);
$this->config = $this->createMock(IConfig::class);
}
/**
@ -109,7 +112,8 @@ class RoomControllerTest extends \Test\TestCase {
$this->dispatcher,
$this->messageParser,
$this->timeFactory,
$this->l
$this->l,
$this->config
);
$controller->setRoom($room);
$controller->setParticipant($participant);

Loading…
Cancel
Save