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.
104 lines
3.7 KiB
104 lines
3.7 KiB
<?= "<?php\n" ?>
|
|
|
|
namespace <?= $namespace; ?>;
|
|
<?php
|
|
function dashesToCamelCase($string, $capitalizeFirstCharacter = false)
|
|
{
|
|
if(strpos($string, '_')!==false){
|
|
$str = str_replace('_', '', ucwords($string, '_'));
|
|
}else{
|
|
$str = str_replace('.', '', ucwords($string, '.'));
|
|
}
|
|
if (!$capitalizeFirstCharacter) {
|
|
$str = lcfirst($str);
|
|
}
|
|
|
|
return $str;
|
|
}
|
|
?>
|
|
<?php if ($panther_is_available): ?>
|
|
use Symfony\Component\Panther\PantherTestCase;
|
|
use Prometeo\CommandsBundle\TestTraits\PantherTrait;
|
|
<?php else: ?>
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
<?php endif ?>
|
|
use Symfony\Component\BrowserKit\Cookie;
|
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
|
use Symfony\Component\HttpFoundation\Session\Session;
|
|
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
|
|
|
|
class <?= $class_name ?> extends <?= $panther_is_available ? 'PantherTestCase' : 'WebTestCase' ?><?= "\n" ?>
|
|
{
|
|
<?php if ($panther_is_available): ?>
|
|
use PantherTrait;
|
|
<?php endif ?>
|
|
private $client = null;
|
|
public function setUp() :void
|
|
{
|
|
// Boot the AppKernel in the test environment and with the debug.
|
|
self::bootKernel();
|
|
<?php if ($panther_is_available): ?>
|
|
$this->client = static::createPantherClient();
|
|
<?php else: ?>
|
|
$this->client = static::createClient();
|
|
<?php endif ?>
|
|
}
|
|
public function testLogin()
|
|
{
|
|
|
|
$crawler = $this->client->request('GET', '/admin');
|
|
$this->client->takeScreenshot('screenshoots/app_login.png');
|
|
$this->assertFileExists('screenshoots/app_login.png');
|
|
$form = $crawler->selectButton('Iniciar sesión')->form();
|
|
$form['_username'] = '<?= $username ?>';
|
|
$form['_password'] = '<?= $password ?>';
|
|
|
|
$crawler = $this->client->submit($form);
|
|
|
|
// $link = $crawler->filter('a:contains("Déconnexion")')->link();
|
|
// $crawler = $client->click($link);
|
|
// $this->assertSame('http://127.0.0.1:9080/es/admin/login', $this->client->getCurrentURL());
|
|
$this->client->takeScreenshot('screenshoots/app_dashboard.png');
|
|
$this->assertFileExists('screenshoots/app_dashboard.png');
|
|
|
|
}
|
|
<?php foreach($routes['routes']['routes'] as $key=>$route){
|
|
$method='';
|
|
if(strpos($route, strtolower('list'))!==false){
|
|
$method='configureListFields';
|
|
}elseif(strpos($route, strtolower('create'))!==false ||strpos($route, strtolower('edit'))!==false){
|
|
$method='configureFormFields';
|
|
}elseif(strpos($route, strtolower('show'))!==false){
|
|
$method='configureShowFields';
|
|
}elseif(strpos($route, strtolower('batch'))!==false){
|
|
$method='configureBatchActions';
|
|
}elseif(strpos($route, strtolower('delete'))!==false){
|
|
$method='delete';
|
|
}elseif(strpos($route, strtolower('export'))!==false){
|
|
$method='configureExportFields';
|
|
}
|
|
?>
|
|
/**
|
|
* @covers App\Admin\<?= str_replace('Test', 'Admin',$class_name) ?>::<?= $method ?>
|
|
* @depends testLogin
|
|
*/
|
|
public function test<?= dashesToCamelCase($route, true) ?>()
|
|
{
|
|
$crawler = $this->client->request('GET', '<?= $routes['routes']['urls'][$key]?>');
|
|
|
|
<?php if ($web_assertions_are_available): ?>
|
|
//$this->assertResponseIsSuccessful();
|
|
<?php else: ?>
|
|
<?php if ($panther_is_available): ?>
|
|
$this->assertEquals(200, $client->getInternalResponse()->getStatusCode());
|
|
<?php else: ?>
|
|
$this->assertEquals(200, $client->getResponse()->getStatusCode());
|
|
<?php endif ?>
|
|
<?php endif ?>
|
|
<?php if ($panther_is_available): ?>
|
|
$this->client->takeScreenshot('screenshoots/<?= $route ?>.png');
|
|
$this->assertFileExists('screenshoots/<?= $route ?>.png');
|
|
<?php endif ?>
|
|
}
|
|
<?php } ?>
|
|
}
|