getContainer(); // only replace the user id $container->registerService('userId', function () { return $this->userId; }); // we do not care about the request but the controller needs it $container->registerService(IRequest::class, function () { return $this->createMock(IRequest::class); }); $this->mapper = $container->query(UserMapper::class); } public function testUpdate() { // create a new user $user = new MatrixUser(); $user->setMatrixUser($this->matrixUserId); $user->setUserId($this->userId); $this->mapper->insert($user); // test that user is in database $result = $this->mapper->find($this->userId); $this->assertEquals($user, $result->getData()); // clean up $this->mapper->delete($result->getData()); } }