You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
<?php
|
|
|
|
namespace App\Tests\Controller;
|
|
|
|
use Symfony\Component\BrowserKit\Client;
|
|
|
|
class RestTestBase extends WebTestCase
|
|
{
|
|
/**
|
|
* @var Client
|
|
*/
|
|
protected $client;
|
|
|
|
protected function setUp()
|
|
{
|
|
parent::setUp();
|
|
$this->client = static::createClient();
|
|
// $this->client->disableReboot(); // uncomment when using prophecy to mock services
|
|
self::reloadDoctrineFixtures();
|
|
}
|
|
|
|
protected function reloadDoctrineFixtures()
|
|
{
|
|
self::runCommand('doctrine:fixtures:load --purge-with-truncate -n');
|
|
}
|
|
|
|
protected function runCommand($command)
|
|
{
|
|
$application = new Application($this->client->getKernel());
|
|
$application->setAutoExit(false);
|
|
return $application->run(new StringInput($command), new NullOutput());
|
|
}
|
|
|
|
protected function createRequestBuilder(string $acceptType = 'application/json'): ClientRequestBuilder
|
|
{
|
|
$builder = new ClientRequestBuilder($this->client);
|
|
$builder->setAcceptType($acceptType);
|
|
return $builder;
|
|
}
|
|
|
|
protected function retrieveEntityManager(): EntityManagerInterface
|
|
{
|
|
return $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
|
}
|
|
} |