Skip to content

Commit

Permalink
Set max_query_count to avoid failing the test of the exception
Browse files Browse the repository at this point in the history
  • Loading branch information
alexislefebvre committed May 13, 2022
1 parent d49fca1 commit 93a080a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tests/AppConfig/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ liip_functional_test:
command_verbosity: "very_verbose"
command_decoration: false
query:
max_query_count: 1
# TODO: it should be 1
max_query_count: 0
authentication:
username: "foobar"
password: "12341234"
2 changes: 1 addition & 1 deletion tests/DependencyInjection/ConfigurationConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function parametersProvider(): array
return [
['command_verbosity', 'very_verbose'],
['command_decoration', false],
['query.max_query_count', 1],
['query.max_query_count', 0],
['authentication.username', 'foobar'],
['authentication.password', '12341234'],
];
Expand Down
34 changes: 28 additions & 6 deletions tests/Test/WebTestCaseConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ public function testIndexAuthenticationLoginClient(): void
* Log in as the user defined in the Data Fixtures and except an
* AllowedQueriesExceededException exception.
*
* There will be 2 queries, in the configuration the limit is 1,
* an Exception will be thrown.
* There will be 2 queries:
* - the user 1 is loaded from the database when logging in
* - the user 2 is loaded by the controller
*
* In the configuration the limit is 1, an Exception will be thrown.
*/
public function testAllowedQueriesExceededException(): void
{
Expand All @@ -194,17 +197,34 @@ public function testAllowedQueriesExceededException(): void
$user
);

$this->loginAs($user, 'secured_area');

$this->client = static::makeClient();

// One another query to load the second user.
$this->loginClient($this->client, $user, 'secured_area');

$path = '/user/2';

$this->expectException(\Liip\FunctionalTestBundle\Exception\AllowedQueriesExceededException::class);

$this->client->request('GET', $path);
$crawler = $this->client->request('GET', $path);

// The following code is called if no exception has been thrown, it should help to understand why
$this->assertStatusCode(200, $this->client);
$this->assertSame(
'LiipFunctionalTestBundle',
$crawler->filter('h1')->text()
);
$this->assertSame(
'Logged in as foo bar.',
$crawler->filter('p#user')->text()
);
$this->assertSame(
'Name: alice bob',
$crawler->filter('div#content p:nth-child(1)')->text()
);
$this->assertSame(
'Email: [email protected]',
$crawler->filter('div#content p:nth-child(2)')->text()
);
}

/**
Expand All @@ -217,6 +237,8 @@ public function testAllowedQueriesExceededException(): void
*/
public function testAnnotationAndException(): void
{
$user = $this->loadTestFixtures();

$this->client = static::makeClient();

// One query to load the second user
Expand Down

0 comments on commit 93a080a

Please sign in to comment.