-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51c8511
commit 9983478
Showing
15 changed files
with
208 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ composer.lock | |
# Cache | ||
.php-cs-fixer.cache | ||
.phplint.cache | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: "#^Unreachable statement \\- code above always terminates\\.$#" | ||
count: 1 | ||
path: ../Tests/Unit/Controller/TranslationControllerTest.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,77 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the package netresearch/nr-textdb. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Netresearch\NrTextdb\Tests\Unit\Controller; | ||
|
||
use Netresearch\NrTextdb\Controller\TranslationController; | ||
use Netresearch\NrTextdb\Domain\Repository\TranslationRepository; | ||
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; | ||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase; | ||
use TYPO3Fluid\Fluid\View\ViewInterface; | ||
|
||
/** | ||
* Test case. | ||
* | ||
* @author Thomas Schöne <[email protected]> | ||
*/ | ||
class TranslationControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase | ||
class TranslationControllerTest extends UnitTestCase | ||
{ | ||
/** | ||
* @var \Netresearch\NrTextdb\Controller\TranslationController | ||
* @var TranslationController | ||
*/ | ||
protected $subject = null; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->subject = $this->getMockBuilder(\Netresearch\NrTextdb\Controller\TranslationController::class) | ||
->setMethods(['redirect', 'forward', 'addFlashMessage']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
parent::tearDown(); | ||
} | ||
protected TranslationController $subject; | ||
|
||
/** | ||
* @test | ||
* @return void | ||
*/ | ||
public function listActionFetchesAllTranslationsFromRepositoryAndAssignsThemToView() | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$allTranslations = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$translationRepository = $this->getMockBuilder(\Netresearch\NrTextdb\Domain\Repository\TranslationRepository::class) | ||
->setMethods(['findAll']) | ||
$this->subject = $this->getMockBuilder(TranslationController::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$translationRepository->expects(self::once())->method('findAll')->will(self::returnValue($allTranslations)); | ||
$this->inject($this->subject, 'translationRepository', $translationRepository); | ||
|
||
$view = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class)->getMock(); | ||
$view->expects(self::once())->method('assign')->with('translations', $allTranslations); | ||
$this->inject($this->subject, 'view', $view); | ||
|
||
$this->subject->listAction(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function showActionAssignsTheGivenTranslationToView() | ||
{ | ||
$translation = new \Netresearch\NrTextdb\Domain\Model\Translation(); | ||
|
||
$view = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class)->getMock(); | ||
$this->inject($this->subject, 'view', $view); | ||
$view->expects(self::once())->method('assign')->with('translation', $translation); | ||
|
||
$this->subject->showAction($translation); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function createActionAddsTheGivenTranslationToTranslationRepository() | ||
public function listActionFetchesAllTranslationsFromRepositoryAndAssignsThemToView(): void | ||
{ | ||
$translation = new \Netresearch\NrTextdb\Domain\Model\Translation(); | ||
self::markTestIncomplete('Rework'); | ||
|
||
$translationRepository = $this->getMockBuilder(\Netresearch\NrTextdb\Domain\Repository\TranslationRepository::class) | ||
->setMethods(['add']) | ||
$allTranslations = $this->getMockBuilder(QueryResultInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$translationRepository->expects(self::once())->method('add')->with($translation); | ||
$this->inject($this->subject, 'translationRepository', $translationRepository); | ||
|
||
$this->subject->createAction($translation); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function editActionAssignsTheGivenTranslationToView() | ||
{ | ||
$translation = new \Netresearch\NrTextdb\Domain\Model\Translation(); | ||
|
||
$view = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface::class)->getMock(); | ||
$this->inject($this->subject, 'view', $view); | ||
$view->expects(self::once())->method('assign')->with('translation', $translation); | ||
|
||
$this->subject->editAction($translation); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function updateActionUpdatesTheGivenTranslationInTranslationRepository() | ||
{ | ||
$translation = new \Netresearch\NrTextdb\Domain\Model\Translation(); | ||
|
||
$translationRepository = $this->getMockBuilder(\Netresearch\NrTextdb\Domain\Repository\TranslationRepository::class) | ||
->setMethods(['update']) | ||
$translationRepository = $this->getMockBuilder(TranslationRepository::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$translationRepository->expects(self::once())->method('update')->with($translation); | ||
$this->inject($this->subject, 'translationRepository', $translationRepository); | ||
$translationRepository | ||
->expects(self::once()) | ||
->method('getAllRecordsByIdentifier') | ||
->willReturn($allTranslations); | ||
|
||
$this->subject->updateAction($translation); | ||
} | ||
$this->inject($this->subject, 'translationRepository', $translationRepository); | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function deleteActionRemovesTheGivenTranslationFromTranslationRepository() | ||
{ | ||
$translation = new \Netresearch\NrTextdb\Domain\Model\Translation(); | ||
$view = $this->getMockBuilder(ViewInterface::class)->getMock(); | ||
|
||
$translationRepository = $this->getMockBuilder(\Netresearch\NrTextdb\Domain\Repository\TranslationRepository::class) | ||
->setMethods(['remove']) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$view | ||
->expects(self::once()) | ||
->method('assign') | ||
->with('translations', $allTranslations); | ||
|
||
$translationRepository->expects(self::once())->method('remove')->with($translation); | ||
$this->inject($this->subject, 'translationRepository', $translationRepository); | ||
$this->inject($this->subject, 'view', $view); | ||
|
||
$this->subject->deleteAction($translation); | ||
$this->subject->listAction(); | ||
} | ||
} |
Oops, something went wrong.