mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Update unit tests base
This commit is contained in:
@@ -894,6 +894,22 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
|||||||
->method('deliver')
|
->method('deliver')
|
||||||
->with($this->isInstanceOf($expectedMail), $this->equalTo($receipt));
|
->with($this->isInstanceOf($expectedMail), $this->equalTo($receipt));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function mockNotificationsDeliverer(array &$expectedMails)
|
||||||
|
{
|
||||||
|
self::$DI['app']['notification.deliverer'] = $this->getMockBuilder('Alchemy\Phrasea\Notification\Deliverer')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$phpunit = $this;
|
||||||
|
|
||||||
|
self::$DI['app']['notification.deliverer']->expects($this->any())
|
||||||
|
->method('deliver')
|
||||||
|
->will($this->returnCallback(function ($email, $receipt) use ($phpunit, &$expectedMails) {
|
||||||
|
$phpunit->assertTrue(isset($expectedMails[get_class($email)]));
|
||||||
|
$expectedMails[get_class($email)]++;
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CsrfTestProvider implements CsrfProviderInterface
|
class CsrfTestProvider implements CsrfProviderInterface
|
||||||
|
@@ -150,6 +150,29 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideFlashMessages()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('warning', 'Be careful !'),
|
||||||
|
array('error', 'An error occured'),
|
||||||
|
array('info', 'You need to do something more'),
|
||||||
|
array('success', "Success operation !"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertFormOrAngularError(Crawler $crawler, $quantity)
|
||||||
|
{
|
||||||
|
$total = $crawler->filter('form div:not(div[ng-show]) > div.popover.field-error')->count();
|
||||||
|
$total += $crawler->filter('phraseanet-flash[type="error"]')->count();
|
||||||
|
|
||||||
|
$this->assertEquals($quantity, $total);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function assertFormError(Crawler $crawler, $quantity)
|
||||||
|
{
|
||||||
|
$this->assertEquals($quantity, $crawler->filter('form div:not(div[ng-show]) > div.popover.field-error')->count());
|
||||||
|
}
|
||||||
|
|
||||||
protected function assertFlashMessage(Crawler $crawler, $flashType, $quantity, $message = null, $offset = 0)
|
protected function assertFlashMessage(Crawler $crawler, $flashType, $quantity, $message = null, $offset = 0)
|
||||||
{
|
{
|
||||||
if (!preg_match('/[a-zA-Z]+/', $flashType)) {
|
if (!preg_match('/[a-zA-Z]+/', $flashType)) {
|
||||||
@@ -163,6 +186,19 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function assertAngularFlashMessage(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('phraseanet-flash[type="'.$flashType.'"]')->count());
|
||||||
|
|
||||||
|
if (null !== $message) {
|
||||||
|
$this->assertEquals($message, $crawler->filter('phraseanet-flash[type="'.$flashType.'"]')->eq($offset)->text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function assertFlashMessagePopulated(Application $app, $flashType, $quantity)
|
protected function assertFlashMessagePopulated(Application $app, $flashType, $quantity)
|
||||||
{
|
{
|
||||||
if (!preg_match('/[a-zA-Z]+/', $flashType)) {
|
if (!preg_match('/[a-zA-Z]+/', $flashType)) {
|
||||||
|
Reference in New Issue
Block a user