2019-03-29 17:53:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Functional;
|
|
|
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
2019-03-29 18:44:22 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Client;
|
2019-03-29 17:53:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class FormatFunctionTest extends WebTestCase
|
|
|
|
{
|
2019-03-29 18:44:22 +01:00
|
|
|
/**
|
|
|
|
* @var Client
|
|
|
|
*/
|
|
|
|
private $client;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
$this->client = static::createClient();
|
|
|
|
}
|
|
|
|
|
2019-03-29 17:53:06 +01:00
|
|
|
public function testHomepage(): void
|
|
|
|
{
|
2019-03-29 18:44:22 +01:00
|
|
|
$this->client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE');
|
|
|
|
$this->assertEquals(200, $this->client->getResponse()
|
|
|
|
->getStatusCode());
|
|
|
|
$this->assertJson($this->client->getResponse()
|
|
|
|
->getContent());
|
2019-03-29 17:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testHomepageWithHTML(): void
|
|
|
|
{
|
2019-03-29 18:44:22 +01:00
|
|
|
$this->client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.html');
|
|
|
|
$this->assertEquals(200, $this->client->getResponse()
|
|
|
|
->getStatusCode());
|
|
|
|
$this->assertContains('<html', $this->client->getResponse()
|
|
|
|
->getContent());
|
2019-03-29 17:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testHomepageWithJSON(): void
|
|
|
|
{
|
2019-03-29 18:44:22 +01:00
|
|
|
$this->client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.json');
|
|
|
|
$this->assertEquals(200, $this->client->getResponse()
|
|
|
|
->getStatusCode());
|
|
|
|
$this->assertJson($this->client->getResponse()
|
|
|
|
->getContent());
|
2019-03-29 17:53:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testHomepageWithXML(): void
|
|
|
|
{
|
2019-03-29 18:44:22 +01:00
|
|
|
$this->client->request(Request::METHOD_GET, 'api/rest/source/HOMEPAGE.xml');
|
|
|
|
$this->assertEquals(200, $this->client->getResponse()
|
|
|
|
->getStatusCode());
|
|
|
|
$content = $this->client->getResponse()->getContent();
|
|
|
|
$xml = new \XMLReader();
|
|
|
|
$xml->XML($content);
|
|
|
|
$xml->setParserProperty(\XMLReader::VALIDATE, true);
|
|
|
|
$this->assertTrue($xml->isValid());
|
2019-03-29 17:53:06 +01:00
|
|
|
}
|
|
|
|
}
|