-
-
Save garak/5926148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyNamespace\CoreBundle\Test; | |
use Symfony\Bundle\FrameworkBundle\Client; | |
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as SymfonyWebTestCase; | |
use Symfony\Component\Process\Process; | |
abstract class WebTestCase extends SymfonyWebTestCase | |
{ | |
protected $container; | |
// feel free to adapt this method, main point is that you get container in $this->container | |
protected function init() | |
{ | |
$kernel = static::createKernel(); | |
$kernel->boot(); | |
$this->container = $kernel->getContainer(); | |
} | |
protected function saveOutput(Client $client, $domain = null, $browser = 'firefox') | |
{ | |
$path = $this->container->get('kernel')->getRootDir() . '/../web/test_out.html'; | |
file_put_contents($path, $client->getResponse()->getContent()); | |
if (!is_null($domain)) { | |
$process = new Process($browser . ' "'.$domain.'/test_out.html"'); | |
$process->run(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyNamespace\CoreBundle\Test; | |
use Symfony\Bundle\FrameworkBundle\Client; | |
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as SymfonyWebTestCase; | |
use Symfony\Component\Process\Process; | |
abstract class WebTestCase extends SymfonyWebTestCase | |
{ | |
protected function saveOutput(Client $client, $domain = null, $delete = true, $browser = 'firefox') | |
{ | |
$path = $this->container->get('kernel')->getRootDir() . '/../web/test_out.html'; | |
file_put_contents($path, $client->getResponse()->getContent()); | |
if (!is_null($domain)) { | |
$process = new Process($browser . ' "'.$domain.'/test_out.html"'); | |
$process->start(); | |
sleep(1); | |
if ($delete) { | |
unlink($path); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyNamespace\CoreBundle\Test; | |
use Symfony\Bundle\FrameworkBundle\Client; | |
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as SymfonyWebTestCase; | |
use Symfony\Component\Process\Process; | |
abstract class WebTestCase extends SymfonyWebTestCase | |
{ | |
protected function saveOutput(Client $client, $domain = null, $delete = true, $browser = 'firefox') | |
{ | |
$path = $this->container->get('kernel')->getRootDir() . '/../web/test_out.html'; | |
file_put_contents($path, $client->getResponse()->getContent()); | |
if (!is_null($domain)) { | |
$process = new Process($browser . ' "'.$domain.'/test_out.html"'); | |
$process->run(function() use($path, $delete) { | |
if ($delete) { | |
unlink($path); | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment