Skip to content

Commit

Permalink
Refactoring with Rector
Browse files Browse the repository at this point in the history
  • Loading branch information
bihor committed Nov 21, 2024
1 parent 0d82c3b commit c9bbf5c
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 78 deletions.
13 changes: 9 additions & 4 deletions Configuration/Backend/Modules.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php

use Fixpunkt\FpMasterquiz\Controller\QuizController;
use Fixpunkt\FpMasterquiz\Controller\QuestionController;
use Fixpunkt\FpMasterquiz\Controller\ParticipantController;

/**
* Definitions for modules provided by EXT:examples
*/
Expand All @@ -13,9 +18,9 @@
'labels' => 'LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_mod1.xlf',
'extensionName' => 'FpMasterquiz',
'controllerActions' => [
\Fixpunkt\FpMasterquiz\Controller\QuizController::class => 'index,detail,charts',
\Fixpunkt\FpMasterquiz\Controller\QuestionController::class => 'move',
\Fixpunkt\FpMasterquiz\Controller\ParticipantController::class => 'list,detail,delete'
QuizController::class => 'index,detail,charts',
QuestionController::class => 'move',
ParticipantController::class => 'list,detail,delete'
],
],
];
];
12 changes: 8 additions & 4 deletions Configuration/Icons.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?php

use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;

return [
'fp_masterquiz-plugin-pi1' => [
'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
'provider' => BitmapIconProvider::class,
'source' => 'EXT:fp_masterquiz/Resources/Public/Icons/user_plugin_pi1.gif'
],
'fp_masterquiz-mod1' => [
'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
'provider' => BitmapIconProvider::class,
'source' => 'EXT:fp_masterquiz/Resources/Public/Icons/user_mod_mod1.gif'
],
'ext-fpmasterquiz-folder-icon' => [
'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
'provider' => SvgIconProvider::class,
'source' => 'EXT:fp_masterquiz/Resources/Public/Icons/ext-fpmasterquiz-folder-icon.svg'
]
];
];
3 changes: 1 addition & 2 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Reference;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Dashboard\Widgets\BarChartWidget;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use Fixpunkt\FpMasterquiz\Widgets\Provider\ParticipantsDataProvider;
Expand Down Expand Up @@ -48,4 +47,4 @@
->arg('$dataProvider', new Reference(ParticipantsDataProvider::class))
->arg('$backendViewFactory', new Reference(BackendViewFactory::class));;
}
};
};
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/pages.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
defined('TYPO3') or die('Access denied.');
defined('TYPO3') || die('Access denied.');

// Override icon
$GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = [
Expand Down
7 changes: 5 additions & 2 deletions Configuration/TCA/Overrides/sys_template.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

ExtensionManagementUtility::addStaticFile(
'fp_masterquiz',
'Configuration/TypoScript',
'Master-Quiz'
);
);
10 changes: 7 additions & 3 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?php

use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

/**
* Register plugins, flexform and remove unused fields
*/
foreach (['list', 'show', 'showbytag', 'intro', 'closure', 'result', 'highscore'] as $plugin) {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
ExtensionUtility::registerPlugin(
'FpMasterquiz',
ucfirst($plugin),
'LLL:EXT:fp_masterquiz/Resources/Private/Language/locallang_be.xlf:template.' . $plugin,
Expand All @@ -12,10 +16,10 @@
);

$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['fpmasterquiz_' . $plugin] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
ExtensionManagementUtility::addPiFlexFormValue(
'fpmasterquiz_' . $plugin,
'FILE:EXT:fp_masterquiz/Configuration/FlexForms/flexform_pi1.xml'
);

// $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['plainfaq_' . $plugin] = 'layout,select_key,pages,recursive';
}
}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# fp_masterquiz

version 5.1.11
version 5.1.12

TYPO3 extension to create a quiz, poll or test. The participant result will be saved in the DB too and can be deleted automatically via Scheduler.

Expand Down Expand Up @@ -51,4 +51,7 @@ Changes in 5.1.9:
- Bugfix: points calculation for modes 3 and 4.

Changes in 5.1.11:
- Bugfix: allow backend-module for users.
- Bugfix: allow backend-module for users.

Changes in 5.1.12:
- Refactoring with the rector-project.
14 changes: 9 additions & 5 deletions Tests/Unit/Controller/ParticipantControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Fixpunkt\FpMasterquiz\Tests\Unit\Controller;

use Fixpunkt\FpMasterquiz\Controller\ParticipantController;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use Fixpunkt\FpMasterquiz\Domain\Repository\ParticipantRepository;
use Fixpunkt\FpMasterquiz\Domain\Model\Participant;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand All @@ -24,7 +28,7 @@ class ParticipantControllerTest extends UnitTestCase
protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder($this->buildAccessibleProxy(\Fixpunkt\FpMasterquiz\Controller\ParticipantController::class))
$this->subject = $this->getMockBuilder($this->buildAccessibleProxy(ParticipantController::class))
->onlyMethods(['redirect', 'forward', 'addFlashMessage'])
->disableOriginalConstructor()
->getMock();
Expand All @@ -40,11 +44,11 @@ protected function tearDown(): void
*/
public function listActionFetchesAllParticipantsFromRepositoryAndAssignsThemToView(): void
{
$allParticipants = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
$allParticipants = $this->getMockBuilder(ObjectStorage::class)
->disableOriginalConstructor()
->getMock();

$participantRepository = $this->getMockBuilder(\Fixpunkt\FpMasterquiz\Domain\Repository\ParticipantRepository::class)
$participantRepository = $this->getMockBuilder(ParticipantRepository::class)
->onlyMethods(['findAll'])
->disableOriginalConstructor()
->getMock();
Expand All @@ -63,9 +67,9 @@ public function listActionFetchesAllParticipantsFromRepositoryAndAssignsThemToVi
*/
public function deleteActionRemovesTheGivenParticipantFromParticipantRepository(): void
{
$participant = new \Fixpunkt\FpMasterquiz\Domain\Model\Participant();
$participant = new Participant();

$participantRepository = $this->getMockBuilder(\Fixpunkt\FpMasterquiz\Domain\Repository\ParticipantRepository::class)
$participantRepository = $this->getMockBuilder(ParticipantRepository::class)
->onlyMethods(['remove'])
->disableOriginalConstructor()
->getMock();
Expand Down
4 changes: 2 additions & 2 deletions Tests/Unit/Controller/QuestionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Fixpunkt\FpMasterquiz\Tests\Unit\Controller;

use Fixpunkt\FpMasterquiz\Controller\QuestionController;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
use TYPO3Fluid\Fluid\View\ViewInterface;

/**
* Test case
Expand All @@ -24,7 +24,7 @@ class QuestionControllerTest extends UnitTestCase
protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder($this->buildAccessibleProxy(\Fixpunkt\FpMasterquiz\Controller\QuestionController::class))
$this->subject = $this->getMockBuilder($this->buildAccessibleProxy(QuestionController::class))
->onlyMethods(['redirect', 'forward', 'addFlashMessage'])
->disableOriginalConstructor()
->getMock();
Expand Down
12 changes: 8 additions & 4 deletions Tests/Unit/Controller/QuizControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Fixpunkt\FpMasterquiz\Tests\Unit\Controller;

use Fixpunkt\FpMasterquiz\Controller\QuizController;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use Fixpunkt\FpMasterquiz\Domain\Repository\QuizRepository;
use Fixpunkt\FpMasterquiz\Domain\Model\Quiz;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand All @@ -24,7 +28,7 @@ class QuizControllerTest extends UnitTestCase
protected function setUp(): void
{
parent::setUp();
$this->subject = $this->getMockBuilder($this->buildAccessibleProxy(\Fixpunkt\FpMasterquiz\Controller\QuizController::class))
$this->subject = $this->getMockBuilder($this->buildAccessibleProxy(QuizController::class))
->onlyMethods(['redirect', 'forward', 'addFlashMessage'])
->disableOriginalConstructor()
->getMock();
Expand All @@ -40,11 +44,11 @@ protected function tearDown(): void
*/
public function listActionFetchesAllQuizzesFromRepositoryAndAssignsThemToView(): void
{
$allQuizzes = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
$allQuizzes = $this->getMockBuilder(ObjectStorage::class)
->disableOriginalConstructor()
->getMock();

$quizRepository = $this->getMockBuilder(\Fixpunkt\FpMasterquiz\Domain\Repository\QuizRepository::class)
$quizRepository = $this->getMockBuilder(QuizRepository::class)
->onlyMethods(['findAll'])
->disableOriginalConstructor()
->getMock();
Expand All @@ -63,7 +67,7 @@ public function listActionFetchesAllQuizzesFromRepositoryAndAssignsThemToView():
*/
public function showActionAssignsTheGivenQuizToView(): void
{
$quiz = new \Fixpunkt\FpMasterquiz\Domain\Model\Quiz();
$quiz = new Quiz();

$view = $this->getMockBuilder(ViewInterface::class)->getMock();
$this->subject->_set('view', $view);
Expand Down
3 changes: 2 additions & 1 deletion Tests/Unit/Domain/Model/AnswerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Fixpunkt\FpMasterquiz\Tests\Unit\Domain\Model;

use Fixpunkt\FpMasterquiz\Domain\Model\Answer;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand All @@ -25,7 +26,7 @@ protected function setUp(): void
parent::setUp();

$this->subject = $this->getAccessibleMock(
\Fixpunkt\FpMasterquiz\Domain\Model\Answer::class,
Answer::class,
['dummy']
);
}
Expand Down
6 changes: 4 additions & 2 deletions Tests/Unit/Domain/Model/EvaluationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Fixpunkt\FpMasterquiz\Tests\Unit\Domain\Model;

use Fixpunkt\FpMasterquiz\Domain\Model\Evaluation;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand All @@ -25,7 +27,7 @@ protected function setUp(): void
parent::setUp();

$this->subject = $this->getAccessibleMock(
\Fixpunkt\FpMasterquiz\Domain\Model\Evaluation::class,
Evaluation::class,
['dummy']
);
}
Expand Down Expand Up @@ -132,7 +134,7 @@ public function getImageReturnsInitialValueForFileReference(): void
*/
public function setImageForFileReferenceSetsImage(): void
{
$fileReferenceFixture = new \TYPO3\CMS\Extbase\Domain\Model\FileReference();
$fileReferenceFixture = new FileReference();
$this->subject->setImage($fileReferenceFixture);

self::assertEquals($fileReferenceFixture, $this->subject->_get('image'));
Expand Down
23 changes: 14 additions & 9 deletions Tests/Unit/Domain/Model/ParticipantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Fixpunkt\FpMasterquiz\Tests\Unit\Domain\Model;

use Fixpunkt\FpMasterquiz\Domain\Model\Participant;
use Fixpunkt\FpMasterquiz\Domain\Model\Quiz;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use Fixpunkt\FpMasterquiz\Domain\Model\Selected;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
Expand All @@ -25,7 +29,7 @@ protected function setUp(): void
parent::setUp();

$this->subject = $this->getAccessibleMock(
\Fixpunkt\FpMasterquiz\Domain\Model\Participant::class,
Participant::class,
['dummy']
);
}
Expand Down Expand Up @@ -321,7 +325,7 @@ public function getQuizReturnsInitialValueForQuiz(): void
*/
public function setQuizForQuizSetsQuiz(): void
{
$quizFixture = new \Fixpunkt\FpMasterquiz\Domain\Model\Quiz();
$quizFixture = new Quiz();
$this->subject->setQuiz($quizFixture);

self::assertEquals($quizFixture, $this->subject->_get('quiz'));
Expand All @@ -332,7 +336,7 @@ public function setQuizForQuizSetsQuiz(): void
*/
public function getSelectionsReturnsInitialValueForSelected(): void
{
$newObjectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$newObjectStorage = new ObjectStorage();
self::assertEquals(
$newObjectStorage,
$this->subject->getSelections()
Expand All @@ -344,9 +348,10 @@ public function getSelectionsReturnsInitialValueForSelected(): void
*/
public function setSelectionsForObjectStorageContainingSelectedSetsSelections(): void
{
$selection = new \Fixpunkt\FpMasterquiz\Domain\Model\Selected();
$objectStorageHoldingExactlyOneSelections = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
$selection = new Selected();
$objectStorageHoldingExactlyOneSelections = new ObjectStorage();
$objectStorageHoldingExactlyOneSelections->attach($selection);

$this->subject->setSelections($objectStorageHoldingExactlyOneSelections);

self::assertEquals($objectStorageHoldingExactlyOneSelections, $this->subject->_get('selections'));
Expand All @@ -357,8 +362,8 @@ public function setSelectionsForObjectStorageContainingSelectedSetsSelections():
*/
public function addSelectionToObjectStorageHoldingSelections(): void
{
$selection = new \Fixpunkt\FpMasterquiz\Domain\Model\Selected();
$selectionsObjectStorageMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
$selection = new Selected();
$selectionsObjectStorageMock = $this->getMockBuilder(ObjectStorage::class)
->onlyMethods(['attach'])
->disableOriginalConstructor()
->getMock();
Expand All @@ -374,8 +379,8 @@ public function addSelectionToObjectStorageHoldingSelections(): void
*/
public function removeSelectionFromObjectStorageHoldingSelections(): void
{
$selection = new \Fixpunkt\FpMasterquiz\Domain\Model\Selected();
$selectionsObjectStorageMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class)
$selection = new Selected();
$selectionsObjectStorageMock = $this->getMockBuilder(ObjectStorage::class)
->onlyMethods(['detach'])
->disableOriginalConstructor()
->getMock();
Expand Down
Loading

0 comments on commit c9bbf5c

Please sign in to comment.