Skip to content

Commit

Permalink
Seb (#467)
Browse files Browse the repository at this point in the history
* add user AbstractFilterSet

* add timeout warning
  • Loading branch information
sebheitzmann authored Aug 29, 2024
1 parent 220df50 commit 40d592a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Test/TestHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
use Lle\CruditBundle\Dto\Layout\LinkElement;
use Lle\CruditBundle\Registry\MenuRegistry;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Component\Clock\Clock;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Stopwatch\Stopwatch;

trait TestHelperTrait
{
protected KernelBrowser $client;
protected RouterInterface $router;

protected function setUp(): void
{
parent::setUp();
Expand All @@ -21,6 +22,7 @@ protected function setUp(): void
/** @var RouterInterface $router */
$router = static::getContainer()->get(RouterInterface::class);
$this->router = $router;
$this->stopwatch = new Stopwatch();

$this->loginUser();
}
Expand All @@ -40,6 +42,7 @@ public function testMenuNav(): void
}
}
}
dump($this->stopwatch);
}

protected function buildClient(): KernelBrowser
Expand All @@ -63,13 +66,17 @@ protected function checkRoute(LinkElement $element): void
}

$url = $this->router->generate($element->getPath()->getRoute(), $element->getPath()->getParams());
$this->stopwatch->start($url);
$this->client->request('GET', $url);

$this->stopwatch->stop($url);
$e = $this->stopwatch->getEvent($url); // dumps e.g. '4.50 MiB - 26 ms'
if ($e->getDuration()>500) {
$this->addWarning("page > 500ms " . $url);
}
$code = $this->client->getResponse()->getStatusCode();
if ($code != '200') {
echo($this->client->getResponse()->getStatusCode());
}

self::assertEquals(
'200',
$code,
Expand All @@ -94,7 +101,13 @@ protected function checkAction(Crawler $elements): void
foreach ($elements as $element) {
foreach ($element->parentNode->attributes as $attribute) {
if ($attribute->nodeName === 'href') {
$this->stopwatch->start($attribute->nodeName);
$this->client->request('GET', $attribute->value);
$this->stopwatch->stop($attribute->nodeName);
$e = $this->stopwatch->getEvent($attribute->nodeName); // dumps e.g. '4.50 MiB - 26 ms'
if ($e->getDuration()>500) {
$this->addWarning("page > 500ms " . $attribute->nodeName);
}
$code = $this->client->getResponse()->getStatusCode();

if ($code != '200') {
Expand Down

0 comments on commit 40d592a

Please sign in to comment.