2019-01-25 22:39:23 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace tests\Unit\Domain\FormManagement;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
|
|
use App\Domain\FormManagement\FormClassNameServiceInterface;
|
2019-02-03 15:21:45 +01:00
|
|
|
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
|
|
|
use App\Entity\Source\PureSource;
|
2019-02-03 16:32:57 +01:00
|
|
|
use App\Domain\FormManagement\RequestedActionFormBuilderService;
|
|
|
|
use App\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
2019-01-25 22:39:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
2019-02-03 16:32:57 +01:00
|
|
|
class RequestedActionFormBuilderServiceTest extends TestCase
|
2019-01-25 22:39:23 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Could be that this test includes a bit to much mocking -.-.
|
|
|
|
*/
|
|
|
|
public function testCreate(): void
|
|
|
|
{
|
|
|
|
$expectedResult = $this->createMock(FormBuilderInterface::class);
|
|
|
|
$formBuilder = $this->createMock(FormBuilderInterface::class);
|
|
|
|
$formBuilder->method('create')->willReturn($expectedResult);
|
|
|
|
$formClassNameService = $this->createMock(FormClassNameServiceInterface::class);
|
2019-02-03 15:21:45 +01:00
|
|
|
$formClassNameService->method('getClass')->willReturn('dummyNamespace');
|
|
|
|
$entity = new PureSource();
|
2019-02-03 16:32:57 +01:00
|
|
|
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
|
|
|
|
$requestedEntity->method('hasIdentity')->willReturn(true);
|
|
|
|
$requestedEntity->method('getEntity')->willReturn($entity);
|
|
|
|
$requestedAction = $this->createMock(RequestedActionServiceInterface::class);
|
|
|
|
$requestedAction->method('getRequestedEntity')->willReturn($requestedEntity);
|
|
|
|
$entityFormBuilderService = new RequestedActionFormBuilderService($formBuilder, $formClassNameService, $requestedAction);
|
|
|
|
$result = $entityFormBuilderService->create($requestedAction);
|
2019-01-25 22:39:23 +01:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
2019-02-03 16:32:57 +01:00
|
|
|
$this->assertEquals($entityFormBuilderService->create($requestedAction), $entityFormBuilderService->createByService());
|
2019-01-25 22:39:23 +01:00
|
|
|
}
|
|
|
|
}
|