Implemented RequestedEntityServiceIntegrationTest

This commit is contained in:
Kevin Frantz 2019-02-15 22:06:14 +01:00
parent 031bff568a
commit c0113ecd32
4 changed files with 62 additions and 14 deletions

View File

@ -36,7 +36,6 @@ services:
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
@ -45,3 +44,7 @@ services:
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
# testing configuration
App\Domain\RequestManagement\Entity\RequestedEntityService:
public: true

View File

@ -16,19 +16,19 @@ use App\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
*/
final class DefaultController extends AbstractController
{
/**
* @deprecated Use load via source instead of fixed route
*
* @todo Optimize function!
* @Route("/imprint.{_format}", defaults={"_format"="json"}, name="imprint")
*/
public function imprint(MVCRoutineServiceInterface $mvcRoutineService, RequestedActionServiceInterface $requestedActionService): Response
{
$requestedActionService->setActionType(ActionType::READ);
$requestedActionService->getRequestedEntity()->setSlug(ImpressumFixtureSource::SLUG);
$view = $mvcRoutineService->process();
$this->handleView($view);
}
// /**
// * @deprecated Use load via source instead of fixed route
// *
// * @todo Optimize function!
// * @Route("/imprint.{_format}", defaults={"_format"="json"}, name="imprint")
// */
// public function imprint(MVCRoutineServiceInterface $mvcRoutineService, RequestedActionServiceInterface $requestedActionService): Response
// {
// // $requestedActionService->setActionType(ActionType::READ);
// // $requestedActionService->getRequestedEntity()->setSlug(ImpressumFixtureSource::SLUG);
// // $view = $mvcRoutineService->process();
// // $this->handleView($view);
// }
/**
* @Route("/", name="homepage")

View File

@ -0,0 +1,8 @@
# Domain Unit Tests
## Conventions
### Service Tests
A test for an service:
- MUST extend KernelTest
- MUST test the actual injection
- MUST be an integration test

View File

@ -0,0 +1,37 @@
<?php
namespace tests\Integration\Domain\RequestManagement\Entity;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use App\Domain\RequestManagement\Entity\RequestedEntityServiceInterface;
use App\Domain\RequestManagement\Entity\RequestedEntityService;
use App\Entity\Source\AbstractSource;
/**
* @author kevinfrantz
*/
class RequestedEntityServiceIntegrationTest extends KernelTestCase
{
/**
* @var RequestedEntityServiceInterface
*/
private $requestedEntityService;
/**
* {@inheritdoc}
*
* @see \PHPUnit\Framework\TestCase::setUp()
*/
public function setUp(): void
{
self::bootKernel();
$this->requestedEntityService = self::$container->get(RequestedEntityService::class);
}
public function testClassAccessors(): void
{
$class = AbstractSource::class;
$this->assertNull($this->requestedEntityService->setClass($class));
$this->assertEquals($class, $this->requestedEntityService->getClass());
}
}