Fix tests

This commit is contained in:
Nicolas Le Goff
2013-10-29 16:53:53 +01:00
parent 9f6389dac8
commit 8b50062011
5 changed files with 21 additions and 17 deletions

View File

@@ -384,8 +384,8 @@ class Login implements ControllerProviderInterface
$appbox_register = new \appbox_register($app['phraseanet.appbox']);
foreach ($selected as $base_id) {
if (false === $inscOK[$base_id] || $user->ACL()->has_access_to_base($base_id)) {
foreach ($inscOK as $base_id => $autorisation) {
if (false === $autorisation || $user->ACL()->has_access_to_base($base_id)) {
continue;
}

View File

@@ -515,6 +515,11 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$parameters[$key] = self::$email;
}
}
if (self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB')) {
unset($parameters['collections']);
}
$crawler = self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
$this->assertFalse(self::$DI['client']->getResponse()->isRedirect());
@@ -527,7 +532,7 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$crawler = self::$DI['client']->request('POST', '/login/register-classic/');
$this->assertFalse(self::$DI['client']->getResponse()->isRedirect());
$this->assertFormOrFlashError($crawler, 8);
$this->assertFormOrFlashError($crawler, self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB') ? 7 : 8);
}
public function provideInvalidRegistrationData()
@@ -613,15 +618,6 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
),
"email" => $this->generateEmail(),
"collections" => null
), array(), 1),
array(array(//no demands
"password" => array(
'password' => 'password',
'confirm' => 'password'
),
"email" => $this->generateEmail(),
"accept-tou" => '1',
"collections" => array()
), array(), 1)
);
}
@@ -955,6 +951,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
}
}
if ( self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB')) {
unset($parameters['collections']);
}
self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
if (false === $userId = \User_Adapter::get_usr_id_from_email(self::$DI['app'], $parameters['email'])) {
@@ -1006,6 +1006,10 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
}
}
if ( self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB')) {
unset($parameters['collections']);
}
self::$DI['client']->request('POST', '/login/register-classic/', $parameters);
if (false === $userId = \User_Adapter::get_usr_id_from_email(self::$DI['app'], $parameters['email'])) {

View File

@@ -51,7 +51,7 @@ class PhraseaRegisterFormTest extends FormTestCase
$form = new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer());
$this->assertCount(8, self::$DI['app']->form($form)->createView()->vars['form']->children);
$this->assertCount(self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB') ? 7 : 8, self::$DI['app']->form($form)->createView()->vars['form']->children);
}
public function testFormDoesNotRegisterNonValidFields()
@@ -75,6 +75,6 @@ class PhraseaRegisterFormTest extends FormTestCase
$form = new PhraseaRegisterForm(self::$DI['app'], $available, $params, new Camelizer());
$this->assertCount(7, self::$DI['app']->form($form)->createView()->vars['form']->children);
$this->assertCount(self::$DI['app']['phraseanet.registry']->get('GV_autoselectDB') ? 6 : 7, self::$DI['app']->form($form)->createView()->vars['form']->children);
}
}

View File

@@ -601,7 +601,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$process = new Symfony\Component\Process\Process('php ' . $command);
$process->run();
} catch (Symfony\Component\Process\Exception\RuntimeException $e) {
$this->fail('Unable to validate ORM schema');
exit('Unable to validate ORM schema');
}
self::$updated = true;

View File

@@ -166,7 +166,7 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
protected function assertFormOrFlashError(Crawler $crawler, $quantity)
{
$total = $crawler->filter('form div:not(div[ng-show]) > div.popover.field-error')->count();
$total = $crawler->filter('.field-error')->count();
$total += $crawler->filter('.alert')->count();
$this->assertEquals($quantity, $total);
@@ -174,7 +174,7 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
protected function assertFormError(Crawler $crawler, $quantity)
{
$this->assertEquals($quantity, $crawler->filter('form div:not(div[ng-show]) > div.popover.field-error')->count());
$this->assertEquals($quantity, $crawler->filter('.field-error')->count());
}
protected function assertFlashMessage(Crawler $crawler, $flashType, $quantity, $message = null, $offset = 0)