Browse Source

Fix dependecy circle

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/8103/head
Joas Schilling 3 years ago
parent
commit
6fe7df6f77
No known key found for this signature in database GPG Key ID: C400AAF20C1BB6FC
  1. 4
      lib/Service/RoomService.php
  2. 7
      tests/php/Chat/ChatManagerTest.php
  3. 2
      tests/php/Chat/SystemMessage/ListenerTest.php
  4. 4
      tests/php/Service/RoomServiceTest.php
  5. 5
      tests/php/Signaling/BackendNotifierTest.php

4
lib/Service/RoomService.php

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace OCA\Talk\Service;
use InvalidArgumentException;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Events\ModifyLobbyEvent;
use OCA\Talk\Events\ModifyRoomEvent;
use OCA\Talk\Events\RoomEvent;
@ -50,7 +49,6 @@ use OCP\Share\IManager as IShareManager;
class RoomService {
protected Manager $manager;
protected ChatManager $chatManager;
protected ParticipantService $participantService;
protected IDBConnection $db;
protected ITimeFactory $timeFactory;
@ -60,7 +58,6 @@ class RoomService {
protected IJobList $jobList;
public function __construct(Manager $manager,
ChatManager $chatManager,
ParticipantService $participantService,
IDBConnection $db,
ITimeFactory $timeFactory,
@ -69,7 +66,6 @@ class RoomService {
IEventDispatcher $dispatcher,
IJobList $jobList) {
$this->manager = $manager;
$this->chatManager = $chatManager;
$this->participantService = $participantService;
$this->db = $db;
$this->timeFactory = $timeFactory;

7
tests/php/Chat/ChatManagerTest.php

@ -34,6 +34,7 @@ use OCA\Talk\Room;
use OCA\Talk\Service\AttachmentService;
use OCA\Talk\Service\ParticipantService;
use OCA\Talk\Service\PollService;
use OCA\Talk\Service\RoomService;
use OCA\Talk\Share\RoomShareProvider;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Collaboration\Reference\IReferenceManager;
@ -65,6 +66,8 @@ class ChatManagerTest extends TestCase {
protected $shareProvider;
/** @var ParticipantService|MockObject */
protected $participantService;
/** @var RoomService|MockObject */
protected $roomService;
/** @var PollService|MockObject */
protected $pollService;
/** @var Notifier|MockObject */
@ -86,6 +89,7 @@ class ChatManagerTest extends TestCase {
$this->shareManager = $this->createMock(IManager::class);
$this->shareProvider = $this->createMock(RoomShareProvider::class);
$this->participantService = $this->createMock(ParticipantService::class);
$this->roomService = $this->createMock(RoomService::class);
$this->pollService = $this->createMock(PollService::class);
$this->notifier = $this->createMock(Notifier::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
@ -101,6 +105,7 @@ class ChatManagerTest extends TestCase {
$this->shareManager,
$this->shareProvider,
$this->participantService,
$this->roomService,
$this->pollService,
$this->notifier,
$cacheFactory,
@ -127,6 +132,7 @@ class ChatManagerTest extends TestCase {
$this->shareManager,
$this->shareProvider,
$this->participantService,
$this->roomService,
$this->pollService,
$this->notifier,
$cacheFactory,
@ -146,6 +152,7 @@ class ChatManagerTest extends TestCase {
$this->shareManager,
$this->shareProvider,
$this->participantService,
$this->roomService,
$this->pollService,
$this->notifier,
$cacheFactory,

2
tests/php/Chat/SystemMessage/ListenerTest.php

@ -82,11 +82,11 @@ class ListenerTest extends TestCase {
$this->timeFactory->method('getDateTime')->willReturn($this->dummyTime);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->handlers = [];
$this->eventDispatcher->method('addListener')
->will($this->returnCallback(function ($eventName, $handler) {
$this->handlers[$eventName] ??= [];
$this->handlers[$eventName][] = $handler;
}));

4
tests/php/Service/RoomServiceTest.php

@ -25,7 +25,6 @@ namespace OCA\Talk\Tests\php\Service;
use InvalidArgumentException;
use OC\EventDispatcher\EventDispatcher;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Events\VerifyRoomPasswordEvent;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Manager;
@ -68,7 +67,6 @@ class RoomServiceTest extends TestCase {
parent::setUp();
$this->manager = $this->createMock(Manager::class);
$this->chatManager = $this->createMock(ChatManager::class);
$this->participantService = $this->createMock(ParticipantService::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->shareManager = $this->createMock(IShareManager::class);
@ -77,7 +75,6 @@ class RoomServiceTest extends TestCase {
$this->jobList = $this->createMock(IJobList::class);
$this->service = new RoomService(
$this->manager,
$this->chatManager,
$this->participantService,
\OC::$server->get(IDBConnection::class),
$this->timeFactory,
@ -348,7 +345,6 @@ class RoomServiceTest extends TestCase {
$service = new RoomService(
$this->manager,
$this->chatManager,
$this->participantService,
\OC::$server->get(IDBConnection::class),
$this->timeFactory,

5
tests/php/Signaling/BackendNotifierTest.php

@ -23,7 +23,6 @@
namespace OCA\Talk\Tests\php\Signaling;
use OCA\Talk\AppInfo\Application;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Chat\CommentsManager;
use OCA\Talk\Config;
use OCA\Talk\Events\SignalingRoomPropertiesEvent;
@ -89,8 +88,6 @@ class BackendNotifierTest extends TestCase {
/** @var IURLGenerator|MockObject */
private $urlGenerator;
private ?\OCA\Talk\Tests\php\Signaling\CustomBackendNotifier $controller = null;
/** @var null|ChatManager|MockObject */
private ?ChatManager $chatManager = null;
private ?Manager $manager = null;
private ?RoomService $roomService = null;
@ -157,12 +154,10 @@ class BackendNotifierTest extends TestCase {
$this->createMock(IHasher::class),
$this->createMock(IL10N::class)
);
$this->chatManager = $this->createMock(ChatManager::class);
$this->jobList = $this->createMock(IJobList::class);
$this->roomService = new RoomService(
$this->manager,
$this->chatManager,
$this->participantService,
$dbConnection,
$this->timeFactory,

Loading…
Cancel
Save