Skip to content

Commit

Permalink
[TASK] Replace prophecy in EXT:backend FormSelectTreeAjaxControllerTest
Browse files Browse the repository at this point in the history
Resolves: #98870
Releases: main
Change-Id: I41b01ca1f2b72721e282f31f9656f995c0164755
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76376
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
  • Loading branch information
derhansen authored and nhovratov committed Nov 2, 2022
1 parent 74784c0 commit 3d59067
Showing 1 changed file with 4 additions and 9 deletions.
Expand Up @@ -17,39 +17,34 @@

namespace TYPO3\CMS\Backend\Tests\Unit\Controller;

use Prophecy\PhpUnit\ProphecyTrait;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Controller\FormSelectTreeAjaxController;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class FormSelectTreeAjaxControllerTest extends UnitTestCase
{
use ProphecyTrait;

/**
* @test
*/
public function fetchDataActionThrowsExceptionIfTcaOfTableDoesNotExist(): void
{
$requestProphecy = $this->prophesize(ServerRequestInterface::class);
$this->expectException(\RuntimeException::class);
$this->expectExceptionCode(1479386729);
(new FormSelectTreeAjaxController())->fetchDataAction($requestProphecy->reveal());
(new FormSelectTreeAjaxController())->fetchDataAction(new ServerRequest());
}

/**
* @test
*/
public function fetchDataActionThrowsExceptionIfTcaOfTableFieldDoesNotExist(): void
{
$requestProphecy = $this->prophesize(ServerRequestInterface::class);
$requestProphecy->getQueryParams()->shouldBeCalled()->willReturn([
$serverRequest = (new ServerRequest())->withQueryParams([
'tableName' => 'aTable',
'fieldName' => 'aField',
]);
$GLOBALS['TCA']['aTable']['columns'] = [];
$this->expectException(\RuntimeException::class);
$this->expectExceptionCode(1479386990);
(new FormSelectTreeAjaxController())->fetchDataAction($requestProphecy->reveal());
(new FormSelectTreeAjaxController())->fetchDataAction($serverRequest);
}
}

0 comments on commit 3d59067

Please sign in to comment.