@@ -29,25 +29,27 @@ Requesting a Page
29
29
Essentially, feature tests simply allows you to call an endpoint on your application and get the results back.
30
30
To do this, you use the ``call() `` method.
31
31
32
- 1. The first parameter is the HTTP method to use (most frequently either GET or POST).
32
+ 1. The first parameter is the HTTP method to use (most frequently either `` GET `` or `` POST `` ).
33
33
2. The second parameter is the URI path on your site to test.
34
34
3. The third parameter ``$params `` accepts an array that is used to populate the
35
35
superglobal variables for the HTTP verb you are using. So, a method of **GET **
36
- would have the ** $_GET ** variable populated, while a **POST ** request would
37
- have the ** $_POST ** array populated. The ``$params `` is also used in
36
+ would have the `` $_GET `` variable populated, while a **POST ** request would
37
+ have the `` $_POST `` array populated. The ``$params `` is also used in
38
38
:ref: `feature-formatting-the-request `.
39
39
40
40
.. note :: The ``$params`` array does not make sense for every HTTP verb, but is
41
41
included for consistency.
42
42
43
43
.. literalinclude :: feature/002.php
44
+ :lines: 2-
44
45
45
46
Shorthand Methods
46
47
-----------------
47
48
48
49
Shorthand methods for each of the HTTP verbs exist to ease typing and make things clearer:
49
50
50
51
.. literalinclude :: feature/003.php
52
+ :lines: 2-
51
53
52
54
Setting Different Routes
53
55
------------------------
@@ -56,6 +58,7 @@ You can use a custom collection of routes by passing an array of "routes" into t
56
58
override any existing routes in the system:
57
59
58
60
.. literalinclude :: feature/004.php
61
+ :lines: 2-
59
62
60
63
Each of the "routes" is a 3 element array containing the HTTP verb (or "add" for all),
61
64
the URI to match, and the routing destination.
@@ -68,6 +71,7 @@ of key/value pairs that should exist within the ``$_SESSION`` variable when this
68
71
that the current values of ``$_SESSION `` should be used. This is handy for testing authentication and more.
69
72
70
73
.. literalinclude :: feature/005.php
74
+ :lines: 2-
71
75
72
76
Setting Headers
73
77
---------------
@@ -76,6 +80,7 @@ You can set header values with the ``withHeaders()`` method. This takes an array
76
80
passed as a header into the call:
77
81
78
82
.. literalinclude :: feature/006.php
83
+ :lines: 2-
79
84
80
85
Bypassing Events
81
86
----------------
@@ -84,6 +89,7 @@ Events are handy to use in your application, but can be problematic during testi
84
89
to send out emails. You can tell the system to skip any event handling with the ``skipEvents() `` method:
85
90
86
91
.. literalinclude :: feature/007.php
92
+ :lines: 2-
87
93
88
94
.. _feature-formatting-the-request :
89
95
@@ -100,6 +106,7 @@ body of the request in the given format.
100
106
This will also set the `Content-Type ` header for your request accordingly.
101
107
102
108
.. literalinclude :: feature/008.php
109
+ :lines: 2-
103
110
104
111
.. _feature-setting-the-body :
105
112
0 commit comments