mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-16 10:16:22 +02:00
Implemented FrameFunctionalTest
This commit is contained in:
parent
2a1b5f2a99
commit
421e8cfdd3
@ -19,6 +19,9 @@
|
|||||||
</php>
|
</php>
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
|
<testsuite name="Functional Test Suite">
|
||||||
|
<directory>./tests/Functional/</directory>
|
||||||
|
</testsuite>
|
||||||
<testsuite name="Integration Test Suite">
|
<testsuite name="Integration Test Suite">
|
||||||
<directory>./tests/Integration/</directory>
|
<directory>./tests/Integration/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Infinito\Domain\ViewManagement;
|
namespace Infinito\Domain\ViewManagement;
|
||||||
|
|
||||||
use FOS\RestBundle\View\View;
|
use FOS\RestBundle\View\View;
|
||||||
@ -6,60 +7,50 @@ use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
|
|||||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||||
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
|
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
|
||||||
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
|
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
|
||||||
use Infinito\Domain\ParameterManagement\OptionalGetParameterService;
|
|
||||||
use Infinito\Domain\ParameterManagement\OptionalGetParameterServiceInterface;
|
use Infinito\Domain\ParameterManagement\OptionalGetParameterServiceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
final class ViewBuilder implements ViewBuilderInterface
|
final class ViewBuilder implements ViewBuilderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var string The path to the atom entity template
|
* @var string The path to the atom entity template
|
||||||
*/
|
*/
|
||||||
const TWIG_ENTITY_ATOM_TEMPLATE_PATH = 'entity/_entity.html.twig';
|
const TWIG_ENTITY_ATOM_TEMPLATE_PATH = 'entity/_entity.html.twig';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var string The path to the molecule entity template
|
* @var string The path to the molecule entity template
|
||||||
*/
|
*/
|
||||||
const TWIG_ENTITY_MOLECULE_TEMPLATE_PATH = 'entity/entity.html.twig';
|
const TWIG_ENTITY_MOLECULE_TEMPLATE_PATH = 'entity/entity.html.twig';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var View
|
* @var View
|
||||||
*/
|
*/
|
||||||
private $view;
|
private $view;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var RequestedActionInterface
|
* @var RequestedActionInterface
|
||||||
*/
|
*/
|
||||||
private $actionService;
|
private $actionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var ActionFactoryServiceInterface
|
* @var ActionFactoryServiceInterface
|
||||||
*/
|
*/
|
||||||
private $actionFactoryService;
|
private $actionFactoryService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var TemplateNameServiceInterface
|
* @var TemplateNameServiceInterface
|
||||||
*/
|
*/
|
||||||
private $templateNameService;
|
private $templateNameService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var OptionalGetParameterServiceInterface
|
* @var OptionalGetParameterServiceInterface
|
||||||
*/
|
*/
|
||||||
private $optionalGetParameterService;
|
private $optionalGetParameterService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Containes the routine to decide if the template should be loaded with or without frame
|
* Containes the routine to decide if the template should be loaded with or without frame.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -68,6 +59,7 @@ final class ViewBuilder implements ViewBuilderInterface
|
|||||||
if ($this->optionalGetParameterService->hasParameter(OptionalGetParameterServiceInterface::FRAME_PARAMETER)) {
|
if ($this->optionalGetParameterService->hasParameter(OptionalGetParameterServiceInterface::FRAME_PARAMETER)) {
|
||||||
return $this->optionalGetParameterService->getParameter(OptionalGetParameterServiceInterface::FRAME_PARAMETER);
|
return $this->optionalGetParameterService->getParameter(OptionalGetParameterServiceInterface::FRAME_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +68,7 @@ final class ViewBuilder implements ViewBuilderInterface
|
|||||||
* Feel free to remove it if this should not be the case.
|
* Feel free to remove it if this should not be the case.
|
||||||
*
|
*
|
||||||
* @todo Implement tests
|
* @todo Implement tests
|
||||||
*
|
*
|
||||||
* @return string The general entity template or a individual template if it is set
|
* @return string The general entity template or a individual template if it is set
|
||||||
*/
|
*/
|
||||||
private function getTemplate(): string
|
private function getTemplate(): string
|
||||||
@ -85,17 +77,18 @@ final class ViewBuilder implements ViewBuilderInterface
|
|||||||
if ($this->templateNameService->doesMoleculeTemplateExist()) {
|
if ($this->templateNameService->doesMoleculeTemplateExist()) {
|
||||||
return $this->templateNameService->getMoleculeTemplateName();
|
return $this->templateNameService->getMoleculeTemplateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::TWIG_ENTITY_MOLECULE_TEMPLATE_PATH;
|
return self::TWIG_ENTITY_MOLECULE_TEMPLATE_PATH;
|
||||||
}
|
}
|
||||||
if ($this->templateNameService->doesAtomTemplateExist()) {
|
if ($this->templateNameService->doesAtomTemplateExist()) {
|
||||||
return $this->templateNameService->getAtomTemplateName();
|
return $this->templateNameService->getAtomTemplateName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::TWIG_ENTITY_ATOM_TEMPLATE_PATH;
|
return self::TWIG_ENTITY_ATOM_TEMPLATE_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param ActionServiceInterface $actionService
|
||||||
* @param ActionServiceInterface $actionService
|
|
||||||
* @param ActionFactoryServiceInterface $actionFactoryService
|
* @param ActionFactoryServiceInterface $actionFactoryService
|
||||||
*/
|
*/
|
||||||
public function __construct(ActionServiceInterface $actionService, ActionFactoryServiceInterface $actionFactoryService, TemplateNameServiceInterface $templateNameService, OptionalGetParameterServiceInterface $optionalGetParameterService)
|
public function __construct(ActionServiceInterface $actionService, ActionFactoryServiceInterface $actionFactoryService, TemplateNameServiceInterface $templateNameService, OptionalGetParameterServiceInterface $optionalGetParameterService)
|
||||||
@ -107,7 +100,6 @@ final class ViewBuilder implements ViewBuilderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function getView(): View
|
public function getView(): View
|
||||||
@ -119,7 +111,6 @@ final class ViewBuilder implements ViewBuilderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @see \Infinito\Domain\ViewManagement\ViewBuilderInterface::getActionService()
|
* @see \Infinito\Domain\ViewManagement\ViewBuilderInterface::getActionService()
|
||||||
@ -130,7 +121,6 @@ final class ViewBuilder implements ViewBuilderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @see \Infinito\Domain\ViewManagement\ViewBuilderInterface::build()
|
* @see \Infinito\Domain\ViewManagement\ViewBuilderInterface::build()
|
||||||
|
45
application/symfony/tests/Functional/FrameFunctionTest.php
Normal file
45
application/symfony/tests/Functional/FrameFunctionTest.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Functional;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
class FrameFunctionTest extends WebTestCase
|
||||||
|
{
|
||||||
|
public function testHomepageWithFrame(): void
|
||||||
|
{
|
||||||
|
$client = static::createClient();
|
||||||
|
$client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html?frame=1');
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
|
$this->assertContains('<html', $client->getResponse()->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHomepageFrameWithoutParameter(): void
|
||||||
|
{
|
||||||
|
$client = static::createClient();
|
||||||
|
$client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html');
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
|
$content = $client->getResponse()->getContent();
|
||||||
|
$this->assertContains('<html', $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHomepageFrameless(): void
|
||||||
|
{
|
||||||
|
$client = static::createClient();
|
||||||
|
$client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html?frame=0');
|
||||||
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
||||||
|
$content = $client->getResponse()->getContent();
|
||||||
|
$this->assertNotContains('<html', $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIncorrectParameterValue(): void
|
||||||
|
{
|
||||||
|
$client = static::createClient();
|
||||||
|
$client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html?frame=true');
|
||||||
|
$this->assertEquals(406, $client->getResponse()->getStatusCode());
|
||||||
|
}
|
||||||
|
}
|
@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace Tests\Integration\Domain\ViewManagement;
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author kevinfrantz
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class ViewBuilderIntegrationTest extends WebTestCase
|
|
||||||
{
|
|
||||||
public function testHomepageFrameless(): void
|
|
||||||
{
|
|
||||||
$client = static::createClient();
|
|
||||||
$client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html?frame=0');
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
|
||||||
$xml = @simplexml_load_string($client->getResponse()->getContent());
|
|
||||||
$this->assertFalse($xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function testHomepageFrameWithoutParameter(): void
|
|
||||||
{
|
|
||||||
$client = static::createClient();
|
|
||||||
$client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html');
|
|
||||||
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
|
||||||
$content = $client->getResponse()->getContent();
|
|
||||||
$xml = @simplexml_load_string($content);
|
|
||||||
$this->assertTrue($xml,"The content <<\n$content\n>> is no valid xml!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @param string $url
|
|
||||||
// * @param int $status
|
|
||||||
// */
|
|
||||||
// public function testHomepageFrameless(): void
|
|
||||||
// {
|
|
||||||
// $client = static::createClient();
|
|
||||||
// $crawler = $client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html?frame=');
|
|
||||||
// $this->assertEquals(200, $client->getResponse()->getStatusCode());
|
|
||||||
// $this->assertEquals(1,$crawler->filter('html')->count());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @param string $url
|
|
||||||
// * @param int $status
|
|
||||||
// */
|
|
||||||
// public function testHomepageExplizitNoFrame(): void
|
|
||||||
// {
|
|
||||||
// $client = static::createClient();
|
|
||||||
// $crawler = $client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html?frame=0');
|
|
||||||
// $this->assertEquals(200, $client->getResponse()->getStatusCode());
|
|
||||||
// $this->assertEquals(1,$crawler->filter('html')->count());
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user