Skip to content

Commit 5fe0572

Browse files
committed
docs: improve feature.rst
1 parent d273222 commit 5fe0572

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

user_guide_src/source/testing/feature.rst

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,31 @@ are called if you implement your own methods.
2121

2222
.. literalinclude:: feature/001.php
2323

24-
Requesting A Page
24+
Requesting a Page
2525
=================
2626

2727
Essentially, feature tests simply allows you to call an endpoint on your application and get the results back.
28-
to do this, you use the ``call()`` method. The first parameter is the HTTP method to use (most frequently either GET or POST).
29-
The second parameter is the path on your site to test. The third parameter accepts an array that is used to populate the
30-
superglobal variables for the HTTP verb you are using. So, a method of **GET** would have the **$_GET** variable
31-
populated, while a **post** request would have the **$_POST** array populated.
28+
To do this, you use the ``call()`` method.
29+
30+
1. The first parameter is the HTTP method to use (most frequently either GET or POST).
31+
2. The second parameter is the URI path on your site to test.
32+
3. The third parameter ``$params`` accepts an array that is used to populate the
33+
superglobal variables for the HTTP verb you are using. So, a method of **GET**
34+
would have the **$_GET** variable populated, while a **POST** request would
35+
have the **$_POST** array populated.
36+
37+
.. note:: The ``$params`` array does not make sense for every HTTP verb, but is
38+
included for consistency.
3239

3340
.. literalinclude:: feature/002.php
3441

42+
Shorthand Methods
43+
-----------------
44+
3545
Shorthand methods for each of the HTTP verbs exist to ease typing and make things clearer:
3646

3747
.. literalinclude:: feature/003.php
3848

39-
.. note:: The ``$params`` array does not make sense for every HTTP verb, but is included for consistency.
40-
4149
Setting Different Routes
4250
------------------------
4351

@@ -74,22 +82,28 @@ to send out emails. You can tell the system to skip any event handling with the
7482

7583
.. literalinclude:: feature/007.php
7684

77-
Formatting The Request
85+
Formatting the Request
7886
-----------------------
7987

8088
You can set the format of your request's body using the ``withBodyFormat()`` method. Currently this supports either
81-
`json` or `xml`. This will take the parameters passed into ``call()``, ``post()``, ``get()``... and assign them to the
82-
body of the request in the given format. This will also set the `Content-Type` header for your request accordingly.
89+
``json`` or ``xml``.
8390
This is useful when testing JSON or XML APIs so that you can set the request in the form that the controller will expect.
8491

92+
This will take the parameters passed into ``call()``, ``post()``, ``get()``... and assign them to the
93+
body of the request in the given format.
94+
95+
This will also set the `Content-Type` header for your request accordingly.
96+
8597
.. literalinclude:: feature/008.php
8698

8799
Setting the Body
88100
----------------
89101

90102
You can set the body of your request with the ``withBody()`` method. This allows you to format the body how you want
91-
to format it. It is recommended that you use this if you have more complicated XMLs to test. This will also not set
92-
the Content-Type header for you so if you need that, you can set it with the ``withHeaders()`` method.
103+
to format it. It is recommended that you use this if you have more complicated XMLs to test.
104+
105+
This will not set
106+
the `Content-Type` header for you. If you need that, you can set it with the ``withHeaders()`` method.
93107

94108
Checking the Response
95109
=====================

0 commit comments

Comments
 (0)