mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 05:23:21 +00:00
Fix phpunit tests
This commit is contained in:
@@ -64,7 +64,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertTrue($response->isOk());
|
||||
$this->assertAngularFlashMessage($crawler, $type, 1, $message);
|
||||
$this->assertFlashMessage($crawler, $type, 1, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +215,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertFalse($response->isRedirect());
|
||||
$this->assertAngularFlashMessage($crawler, 'error', 1);
|
||||
$this->assertFlashMessage($crawler, 'error', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,7 +254,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertFalse($response->isRedirect());
|
||||
$this->assertAngularFlashMessage($crawler, 'error', 1);
|
||||
$this->assertFlashMessage($crawler, 'error', 1);
|
||||
}
|
||||
|
||||
public function testRenewPasswordBadToken()
|
||||
@@ -353,7 +353,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
|
||||
$this->assertTrue(self::$DI['client']->getResponse()->isOk());
|
||||
|
||||
$this->assertAngularFlashMessage($crawler, $type, 1, $message);
|
||||
$this->assertFlashMessage($crawler, $type, 1, $message);
|
||||
}
|
||||
|
||||
public function testForgotPasswordGet()
|
||||
@@ -399,7 +399,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$response = self::$DI['client']->getResponse();
|
||||
$this->assertFalse($response->isRedirect());
|
||||
|
||||
$this->assertAngularFlashMessage($crawler, 'error', 1);
|
||||
$this->assertFlashMessage($crawler, 'error', 1);
|
||||
}
|
||||
|
||||
public function testForgotPasswordSubmission()
|
||||
@@ -430,7 +430,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$response = self::$DI['client']->getResponse();
|
||||
|
||||
$this->assertTrue($response->isOk());
|
||||
$this->assertAngularFlashMessage($crawler, $type, 1, $message);
|
||||
$this->assertFlashMessage($crawler, $type, 1, $message);
|
||||
}
|
||||
|
||||
public function testGetRegisterWithRegisterIdBindDataToForm()
|
||||
@@ -510,7 +510,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$crawler = self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
|
||||
|
||||
$this->assertFalse(self::$DI['client']->getResponse()->isRedirect());
|
||||
$this->assertFormOrAngularError($crawler, $errors);
|
||||
$this->assertFormOrFlashError($crawler, $errors);
|
||||
}
|
||||
|
||||
public function testPostRegisterWithoutParams()
|
||||
@@ -519,7 +519,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
||||
$crawler = self::$DI['client']->request('POST', '/login/register-classic/');
|
||||
|
||||
$this->assertFalse(self::$DI['client']->getResponse()->isRedirect());
|
||||
$this->assertFormOrAngularError($crawler, 9);
|
||||
$this->assertFormOrFlashError($crawler, 9);
|
||||
}
|
||||
|
||||
public function provideInvalidRegistrationData()
|
||||
|
@@ -164,10 +164,10 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
|
||||
);
|
||||
}
|
||||
|
||||
protected function assertFormOrAngularError(Crawler $crawler, $quantity)
|
||||
protected function assertFormOrFlashError(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();
|
||||
$total += $crawler->filter('.alert')->count();
|
||||
|
||||
$this->assertEquals($quantity, $total);
|
||||
}
|
||||
@@ -190,19 +190,6 @@ 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)
|
||||
{
|
||||
if (!preg_match('/[a-zA-Z]+/', $flashType)) {
|
||||
|
Reference in New Issue
Block a user