Skip to content

Commit 5982f3c

Browse files
committed
Use the new api provided by the WebTestAssertionsTrait
1 parent d262c2c commit 5982f3c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Maker/MakeFunctionalTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Console\Input\InputArgument;
2121
use Symfony\Component\Console\Input\InputInterface;
2222
use Symfony\Component\CssSelector\CssSelectorConverter;
23+
use Symfony\Bundle\FrameworkBundle\Test\WebTestAssertionsTrait;
2324

2425
/**
2526
* @author Javier Eguiluz <[email protected]>
@@ -52,7 +53,9 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
5253
$generator->generateClass(
5354
$testClassNameDetails->getFullName(),
5455
'test/Functional.tpl.php',
55-
[]
56+
[
57+
'web_assertions_are_available' => class_exists(WebTestAssertionsTrait::class),
58+
]
5659
);
5760

5861
$generator->writeChanges();

src/Resources/skeleton/test/Functional.tpl.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ public function testSomething()
1111
$client = static::createClient();
1212
$crawler = $client->request('GET', '/');
1313

14+
<?php if($web_assertions_are_available) { ?>
15+
$this->assertResponseIsSuccessful();
16+
$this->assertSelectorTextContains('h1', 'Hello World');
17+
<?php } else { ?>
1418
$this->assertSame(200, $client->getResponse()->getStatusCode());
1519
$this->assertContains('Hello World', $crawler->filter('h1')->text());
20+
<?php } ?>
1621
}
1722
}

0 commit comments

Comments
 (0)