-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The file array was missing
- Loading branch information
kevin
committed
Oct 14, 2012
1 parent
6e69f44
commit 2946e29
Showing
1 changed file
with
36 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
.. index:: | ||
single: Tests; HTTP authentication | ||
|
||
How to simulate HTTP Authentication in a Functional Test | ||
======================================================== | ||
|
||
If your application needs HTTP authentication, pass the username and password | ||
as server variables to ``createClient()``:: | ||
|
||
$client = static::createClient(array(), array( | ||
'PHP_AUTH_USER' => 'username', | ||
'PHP_AUTH_PW' => 'pa$$word', | ||
)); | ||
|
||
You can also override it on a per request basis:: | ||
|
||
$client->request('DELETE', '/post/12', array(), array( | ||
'PHP_AUTH_USER' => 'username', | ||
'PHP_AUTH_PW' => 'pa$$word', | ||
)); | ||
|
||
When your application is using a ``form_login``, you can simplify your tests | ||
by allowing your test configuration to make use of HTTP authentication. This | ||
way you can use the above to authenticate in tests, but still have your users | ||
login via the normal ``form_login``. The trick is to include the ``http_basic`` | ||
key in your firewall, along with the ``form_login`` key: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
# app/config/config_test.yml | ||
security: | ||
firewalls: | ||
your_firewall_name: | ||
http_basic: | ||
.. index:: | ||
single: Tests; HTTP authentication | ||
|
||
How to simulate HTTP Authentication in a Functional Test | ||
======================================================== | ||
|
||
If your application needs HTTP authentication, pass the username and password | ||
as server variables to ``createClient()``:: | ||
|
||
$client = static::createClient(array(), array( | ||
'PHP_AUTH_USER' => 'username', | ||
'PHP_AUTH_PW' => 'pa$$word', | ||
)); | ||
|
||
You can also override it on a per request basis:: | ||
|
||
$client->request('DELETE', '/post/12', array(), array(), array( | ||
'PHP_AUTH_USER' => 'username', | ||
'PHP_AUTH_PW' => 'pa$$word', | ||
)); | ||
|
||
When your application is using a ``form_login``, you can simplify your tests | ||
by allowing your test configuration to make use of HTTP authentication. This | ||
way you can use the above to authenticate in tests, but still have your users | ||
login via the normal ``form_login``. The trick is to include the ``http_basic`` | ||
key in your firewall, along with the ``form_login`` key: | ||
|
||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
# app/config/config_test.yml | ||
security: | ||
firewalls: | ||
your_firewall_name: | ||
http_basic: |