mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Add flash messages tests
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Silex\WebTestCase;
|
||||
use Silex\Application;
|
||||
use Symfony\Component\HttpKernel\Client;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
{
|
||||
@@ -149,4 +149,26 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
}
|
||||
|
||||
protected function assertFlashMessage(Crawler $crawler, $flashType, $quantity, $message = null, $offset = 0)
|
||||
{
|
||||
if (!preg_match('/[a-zA-Z]+/', $flashType)) {
|
||||
$this->fail(sprintf('FlashType must be in the form of [a-zA-Z]+, %s given', $flashType));
|
||||
}
|
||||
|
||||
$this->assertEquals($quantity, $crawler->filter('.alert.alert-'.$flashType)->count());
|
||||
|
||||
if (null !== $message) {
|
||||
$this->assertEquals($message, $crawler->filter('.alert.alert-'.$flashType.' .alert-block-content')->eq($offset)->text());
|
||||
}
|
||||
}
|
||||
|
||||
protected function assertFlashMessagePopulated(Application $app, $flashType, $quantity)
|
||||
{
|
||||
if (!preg_match('/[a-zA-Z]+/', $flashType)) {
|
||||
$this->fail(sprintf('FlashType must be in the form of [a-zA-Z]+, %s given', $flashType));
|
||||
}
|
||||
|
||||
$this->assertEquals($quantity, count($app['session']->getFlashBag()->get($flashType)));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user