Skip to content

Commit 8d44968

Browse files
replace the Controller class to AbstractController, fix tests
1 parent 88aec12 commit 8d44968

14 files changed

+16
-16
lines changed

Controller/JsonController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace MauticPlugin\CustomObjectsBundle\Controller;
66

7-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
88
use Symfony\Component\HttpFoundation\JsonResponse;
99

10-
class JsonController extends Controller
10+
class JsonController extends AbstractController
1111
{
1212
/**
1313
* Adds flashes stored in session (by addFlash() method) to the JsonResponse.

Tests/Unit/Controller/ControllerTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Mautic\CoreBundle\Model\NotificationModel;
1313
use Mautic\CoreBundle\Security\Permissions\CorePermissions;
1414
use PHPUnit\Framework\MockObject\MockObject;
15-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1616
use Symfony\Component\DependencyInjection\ContainerInterface;
1717
use Symfony\Component\HttpFoundation\HeaderBag;
1818
use Symfony\Component\HttpFoundation\ParameterBag;
@@ -73,7 +73,7 @@ protected function setUp(): void
7373
$this->managerRegistry = $this->createMock(ManagerRegistry::class);
7474
}
7575

76-
protected function addSymfonyDependencies(CommonController|Controller $controller): void
76+
protected function addSymfonyDependencies(AbstractController $controller): void
7777
{
7878
$requestStack = empty($this->requestStack) ? $this->createMock(RequestStack::class) : $this->requestStack;
7979
$request = empty($this->request) ? $this->createMock(Request::class) : $this->request;

Tests/Unit/Controller/CustomField/FormControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function setUp(): void
4949

5050
$this->translator = $this->createMock(Translator::class);
5151

52-
$this->formController = new FormController();
52+
$this->formController = new FormController($this->managerRegistry);
5353
$this->formController->setTranslator($this->translator);
5454
$this->formController->setSecurity($this->security);
5555

Tests/Unit/Controller/CustomField/SaveControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function setUp(): void
5151

5252
$this->translator = $this->createMock(Translator::class);
5353
$this->security = $this->createMock(CorePermissions::class);
54-
$this->saveController = new SaveController();
54+
$this->saveController = new SaveController($this->managerRegistry);
5555
$this->saveController->setTranslator($this->translator);
5656
$this->saveController->setSecurity($this->security);
5757

Tests/Unit/Controller/CustomItem/BatchDeleteControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function setUp(): void
6464
->method('getModel')
6565
->willReturn($this->model);
6666

67-
$this->batchDeleteController = new BatchDeleteController();
67+
$this->batchDeleteController = new BatchDeleteController($this->managerRegistry);
6868
$this->batchDeleteController->setTranslator($this->translator);
6969
$this->batchDeleteController->setSecurity($this->security);
7070
$this->batchDeleteController->setModelFactory($this->modelFactory);

Tests/Unit/Controller/CustomItem/CancelControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp(): void
4444
->method('getCurrentRequest')
4545
->willReturn($this->request);
4646

47-
$this->cancelController = new CancelController();
47+
$this->cancelController = new CancelController($this->managerRegistry);
4848

4949
$this->addSymfonyDependencies($this->cancelController);
5050

Tests/Unit/Controller/CustomItem/DeleteControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function setUp(): void
6464
$this->modelFactory = $this->createMock(ModelFactory::class);
6565
$this->model = $this->createMock(NotificationModel::class);
6666

67-
$this->deleteController = new DeleteController();
67+
$this->deleteController = new DeleteController($this->managerRegistry);
6868
$this->deleteController->setTranslator($this->translator);
6969
$this->deleteController->setSecurity($this->security);
7070
$this->deleteController->setModelFactory($this->modelFactory);

Tests/Unit/Controller/CustomItem/ListControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected function setUp(): void
6060
$this->modelFactory = $this->createMock(ModelFactory::class);
6161
$this->model = $this->createMock(NotificationModel::class);
6262

63-
$this->listController = new ListController();
63+
$this->listController = new ListController($this->managerRegistry);
6464
$this->listController->setTranslator($this->translator);
6565
$this->listController->setModelFactory($this->modelFactory);
6666
$this->listController->setSecurity($this->security);

Tests/Unit/Controller/CustomItem/SaveControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected function setUp(): void
103103
$this->form = $this->createMock(FormInterface::class);
104104

105105
$this->translator = $this->createMock(Translator::class);
106-
$this->saveController = new SaveController($this->security, $this->userHelper);
106+
$this->saveController = new SaveController($this->security, $this->userHelper, $this->managerRegistry);
107107
$this->saveController->setTranslator($this->translator);
108108

109109
$this->addSymfonyDependencies($this->saveController);

Tests/Unit/Controller/CustomItem/ViewControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function setUp(): void
6363

6464
$this->translator = $this->createMock(Translator::class);
6565

66-
$this->viewController = new ViewController();
66+
$this->viewController = new ViewController($this->managerRegistry);
6767
$this->viewController->setTranslator($this->translator);
6868
$this->viewController->setSecurity($this->security);
6969

0 commit comments

Comments
 (0)