PHP code example of intaro / symfony-testing-tools
1. Go to this page and download the library: Download intaro/symfony-testing-tools library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
intaro / symfony-testing-tools example snippets
$client = static::getClient();
$client = static::getClient(true);
namespace Foo\BarBundle\Tests\Controller;
use Intaro\SymfonyTestingTools\WebTestCase;
class SomeControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::getClient(true);
//...
}
}
namespace Foo\BarBundle\Tests\Controller;
use Intaro\SymfonyTestingTools\WebTestCase;
class SomeControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::getClient(true);
$em = static::getEntityManager();
$service = static::getContainer()->get('some_service');
//...
}
}
namespace Foo\BarBundle\Tests\Controller;
use Intaro\SymfonyTestingTools\WebTestCase;
class SomeControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::getClient();
$client->request('GET', '/foo/bar/index');
$this->assertResponseOk($client->getResponse(), 'Page opens');
$this->assertResponseRedirect($client->getResponse(), 'Page redirects to other page');
$this->assertResponseNotFound($client->getResponse(), 'Page not found');
$this->assertResponseForbidden($client->getResponse(), 'Page forbidden');
$this->assertResponseCode(201, $client->getResponse(), 'JSON returned', 'application/json');
}
}
namespace Foo\BarBundle\Tests\Controller;
use Foo\BarBundle\DataFixtures\ORM\Test\ActionRecordData;
use Intaro\SymfonyTestingTools\WebTestCase;
class SomeControllerTest extends WebTestCase
{
public static function setUpBeforeClass()
{
static::appendFixture(new ActionRecordData, [
'purge' => true,
]);
}
public function testIndex()
{
//...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.