infinito/application/symfony/tests/Integration/Domain/Form/RequestedActionFormBuilderServiceIntegrationTest.php

62 lines
2.2 KiB
PHP
Raw Normal View History

<?php
2019-05-30 16:13:29 +02:00
namespace tests\Integration\Domain\Form;
2020-04-02 21:13:35 +02:00
use Infinito\DBAL\Types\ActionType;
2019-05-30 16:13:29 +02:00
use Infinito\Domain\Form\RequestedActionFormBuilderService;
2020-04-02 21:13:35 +02:00
use Infinito\Domain\Form\RequestedActionFormBuilderServiceInterface;
use Infinito\Domain\Request\Action\RequestedActionServiceInterface;
2020-04-02 21:13:35 +02:00
use Infinito\Domain\Request\Entity\RequestedEntityInterface;
use Infinito\Domain\Request\Entity\RequestedEntityServiceInterface;
use Infinito\Entity\Source\PureSource;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2019-02-12 18:27:52 +01:00
use Symfony\Component\Form\Form;
2020-04-02 21:13:35 +02:00
use Symfony\Component\Form\FormBuilderInterface;
/**
* @author kevinfrantz
*/
class RequestedActionFormBuilderServiceIntegrationTest extends KernelTestCase
{
/**
* @var RequestedActionServiceInterface
*/
private $requestedActionService;
/**
* @var RequestedActionFormBuilderService
*/
private $requestedActionFormBuilderService;
/**
* @var RequestedEntityInterface
*/
private $requestedEntity;
/**
* {@inheritdoc}
*
* @see \PHPUnit\Framework\TestCase::setUp()
*/
public function setUp(): void
{
self::bootKernel();
$this->requestedActionFormBuilderService = self::$container->get(RequestedActionFormBuilderServiceInterface::class);
$this->requestedEntity = self::$container->get(RequestedEntityServiceInterface::class);
$this->requestedActionService = self::$container->get(RequestedActionServiceInterface::class);
$this->requestedActionService->setActionType(ActionType::CREATE);
}
public function testCreate(): void
{
$class = PureSource::class;
$this->requestedEntity->setClass($class);
$result = $this->requestedActionFormBuilderService->create($this->requestedActionService);
$this->assertInstanceOf(FormBuilderInterface::class, $result);
2019-02-12 18:27:52 +01:00
$this->assertInstanceOf(Form::class, $result->getForm());
$this->assertTrue(method_exists($result->getForm(), 'isValid'));
//Tests if the origine builder and the service function return the same value by the requestedActionService
$this->assertEquals($this->requestedActionFormBuilderService->create($this->requestedActionService), $this->requestedActionFormBuilderService->createByService());
}
}