Last active
October 31, 2019 14:08
-
-
Save flug/570c9f6aa0155aed260c5b7d8cd8fbd3 to your computer and use it in GitHub Desktop.
[SmokeFunctionalTest] #php #symfony
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 App\Tests; | |
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | |
class SmokeFunctionalTest extends WebTestCase | |
{ | |
/** | |
* @dataProvider urlProvider | |
*/ | |
public function testPageIsSuccessful($url) | |
{ | |
$client = self::createClient(); | |
$client->request('GET', $url); | |
$this->assertContains($client->getResponse()->getStatusCode(), [200, 302, 403, 400]); | |
} | |
public function urlProvider() | |
{ | |
self::bootKernel(); | |
$container = self::$kernel->getContainer(); | |
foreach ($container->get('router')->getRouteCollection()->all() as $route) { | |
if (in_array('GET', $route->getMethods()) && !(bool)strpos($route->getPath(), '{')) { | |
yield [$route->getPath()]; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment