MainControllerTest now checks non-existing user search scenario.
This commit is contained in:
parent
6e5e0435ac
commit
d988bac7b0
|
@ -9,11 +9,9 @@ class MainControllerTest extends WebTestCase
|
||||||
public function testUserSearch()
|
public function testUserSearch()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = static::createClient();
|
||||||
|
|
||||||
$crawler = $client->request('GET', '/');
|
$crawler = $client->request('GET', '/');
|
||||||
|
|
||||||
$userSearchForm = $crawler->filter('form.form-inline')->form();
|
$userSearchForm = $crawler->filter('form.form-inline')->form();
|
||||||
|
|
||||||
$userSearchForm['skobkin_bundle_pointtoolsbundle_user_search[login]'] = 'testuser';
|
$userSearchForm['skobkin_bundle_pointtoolsbundle_user_search[login]'] = 'testuser';
|
||||||
|
|
||||||
$crawler = $client->submit($userSearchForm);
|
$crawler = $client->submit($userSearchForm);
|
||||||
|
@ -21,6 +19,36 @@ class MainControllerTest extends WebTestCase
|
||||||
$this->assertTrue($client->getResponse()->isRedirect('/user/testuser'), 'Redirect to testuser\'s page didn\'t happen');
|
$this->assertTrue($client->getResponse()->isRedirect('/user/testuser'), 'Redirect to testuser\'s page didn\'t happen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNonExistingUserSearch()
|
||||||
|
{
|
||||||
|
$client = static::createClient();
|
||||||
|
$crawler = $client->request('GET', '/');
|
||||||
|
|
||||||
|
$userSearchForm = $crawler->filter('form.form-inline')->form();
|
||||||
|
$userSearchForm['skobkin_bundle_pointtoolsbundle_user_search[login]'] = 'non-existing-user';
|
||||||
|
|
||||||
|
$crawler = $client->submit($userSearchForm);
|
||||||
|
|
||||||
|
$this->assertFalse($client->getResponse()->isRedirection(), 'Redirect to non-existing user on the main page');
|
||||||
|
|
||||||
|
$formElement = $crawler->filter('form.form-inline')->first();
|
||||||
|
|
||||||
|
$this->assertEquals(1, $formElement->count(), 'Form not found after searching non-existing user');
|
||||||
|
|
||||||
|
$loginInputElement = $formElement->filter('#skobkin_bundle_pointtoolsbundle_user_search_login')->first();
|
||||||
|
|
||||||
|
$this->assertEquals(1, $loginInputElement->count(), 'Login form input element not found after search of non existing user');
|
||||||
|
|
||||||
|
$errorsListElement = $loginInputElement->siblings()->filter('span.help-block')->children()->filter('ul.list-unstyled')->first();
|
||||||
|
|
||||||
|
$this->assertEquals(1, $errorsListElement->count(), 'Form errors list not found after search of non-existing user');
|
||||||
|
|
||||||
|
$firstError = $errorsListElement->children()->first();
|
||||||
|
|
||||||
|
$this->assertEquals(1, $firstError->count(), 'No errors in the list');
|
||||||
|
$this->assertEquals(' Login not found', $firstError->text(), 'Incorrect error text');
|
||||||
|
}
|
||||||
|
|
||||||
public function testUserStats()
|
public function testUserStats()
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$client = static::createClient();
|
||||||
|
|
Loading…
Reference in a new issue