Skip to content

Commit f4c8b5f

Browse files
authored
Merge pull request #8494 from kenjis/docs-testing/feature.rst
docs: improve testing/feature.rst
2 parents 02942c4 + de8d908 commit f4c8b5f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

user_guide_src/source/testing/feature.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,27 @@ Requesting a Page
2929
Essentially, feature tests simply allows you to call an endpoint on your application and get the results back.
3030
To do this, you use the ``call()`` method.
3131

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``).
3333
2. The second parameter is the URI path on your site to test.
3434
3. The third parameter ``$params`` accepts an array that is used to populate the
3535
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
3838
:ref:`feature-formatting-the-request`.
3939

4040
.. note:: The ``$params`` array does not make sense for every HTTP verb, but is
4141
included for consistency.
4242

4343
.. literalinclude:: feature/002.php
44+
:lines: 2-
4445

4546
Shorthand Methods
4647
-----------------
4748

4849
Shorthand methods for each of the HTTP verbs exist to ease typing and make things clearer:
4950

5051
.. literalinclude:: feature/003.php
52+
:lines: 2-
5153

5254
Setting Different Routes
5355
------------------------
@@ -56,6 +58,7 @@ You can use a custom collection of routes by passing an array of "routes" into t
5658
override any existing routes in the system:
5759

5860
.. literalinclude:: feature/004.php
61+
:lines: 2-
5962

6063
Each of the "routes" is a 3 element array containing the HTTP verb (or "add" for all),
6164
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
6871
that the current values of ``$_SESSION`` should be used. This is handy for testing authentication and more.
6972

7073
.. literalinclude:: feature/005.php
74+
:lines: 2-
7175

7276
Setting Headers
7377
---------------
@@ -76,6 +80,7 @@ You can set header values with the ``withHeaders()`` method. This takes an array
7680
passed as a header into the call:
7781

7882
.. literalinclude:: feature/006.php
83+
:lines: 2-
7984

8085
Bypassing Events
8186
----------------
@@ -84,6 +89,7 @@ Events are handy to use in your application, but can be problematic during testi
8489
to send out emails. You can tell the system to skip any event handling with the ``skipEvents()`` method:
8590

8691
.. literalinclude:: feature/007.php
92+
:lines: 2-
8793

8894
.. _feature-formatting-the-request:
8995

@@ -100,6 +106,7 @@ body of the request in the given format.
100106
This will also set the `Content-Type` header for your request accordingly.
101107

102108
.. literalinclude:: feature/008.php
109+
:lines: 2-
103110

104111
.. _feature-setting-the-body:
105112

user_guide_src/source/testing/feature/001.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22

3-
namespace App;
3+
namespace Tests\Feature;
44

5+
use CodeIgniter\Test\CIUnitTestCase;
56
use CodeIgniter\Test\DatabaseTestTrait;
67
use CodeIgniter\Test\FeatureTestTrait;
78

8-
class TestFoo extends CIUnitTestCase
9+
class FooTest extends CIUnitTestCase
910
{
1011
use DatabaseTestTrait;
1112
use FeatureTestTrait;

0 commit comments

Comments
 (0)