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;
|
|
|
|
use App\Domain\FormManagement\RequestedEntityFormBuilderService;
|
2019-01-25 22:39:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class EntityFormBuilderServiceTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 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');
|
|
|
|
$entityFormBuilderService = new RequestedEntityFormBuilderService($formBuilder, $formClassNameService);
|
|
|
|
$entity = new PureSource();
|
|
|
|
$entityRequested = $this->createMock(RequestedEntityInterface::class);
|
|
|
|
$entityRequested->method('hasIdentity')->willReturn(true);
|
|
|
|
$entityRequested->method('getEntity')->willReturn($entity);
|
|
|
|
$result = $entityFormBuilderService->create($entityRequested);
|
2019-01-25 22:39:23 +01:00
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
}
|
|
|
|
}
|