Skip to content

Commit e1d3ec2

Browse files
pluchtsebastianbergmann
authored andcommitted
add a more elaborate description of @testwith
This addresses issue #37.
1 parent bc72d5a commit e1d3ec2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/annotations.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,13 @@ The ``@testdox`` annotation can be applied to both test classes and test methods
773773
Instead of implementing a method for use with ``@dataProvider``,
774774
you can define a data set using the ``@testWith`` annotation.
775775

776+
A data set consists of one or many elements. To define a data set
777+
with multiple elements, define each element in a separate line.
778+
Each element of the data set must be an array defined in JSON.
779+
780+
See :ref:`writing-tests-for-phpunit.data-providers` to learn
781+
more about passing a set of data to a test.
782+
776783
.. code-block:: php
777784
778785
/**
@@ -787,6 +794,21 @@ you can define a data set using the ``@testWith`` annotation.
787794
$this->assertSame($expectedLength, strlen($input));
788795
}
789796
797+
An object representation in JSON will be converted into an associative array.
798+
799+
.. code-block:: php
800+
801+
/**
802+
* @param array $array
803+
* @param array $keys
804+
*
805+
* @testWith [{"day": "monday", "conditions": "sunny"}, ["day", "conditions"]]
806+
*/
807+
public function testArrayKeys($array, $keys)
808+
{
809+
$this->assertSame($keys, array_keys($array));
810+
}
811+
790812
.. _appendixes.annotations.ticket:
791813

792814
@ticket

0 commit comments

Comments
 (0)