In Chapter 5: Unit Testing 101,
Section: Making the Test Pass,
pages: 57 and 58 (PDF version):
The signature of the function link_to() causes $parameters variable to be treated as a string and PHPUnit gives the following error:
- INFO - PHPUnit 3.7.22 by Sebastian Bergmann.
> [#]
> [#] Configuration read from /Users/tolga/Sites/lesson/phpunit.xml
> [#]
> [#] {"error":{"type":"ErrorException","message":"Invalid argument supplied for foreach()","file":"\/Users\/tolga\/Sites\/lesson\/app\/helpers.php","line":8}}
Signature of the function
function link_to($url, $body, $parameters = null)
line where error occurs
foreach($parameters as $attribute => $value)
I am not sure if this error occurs due to a configuration flag in my PHP installation (using 5.5.1), but it can be fixed by either using $parameters = array() or $parameters = [] for the last argument.
In Chapter 5: Unit Testing 101, Section: Making the Test Pass, pages: 57 and 58 (PDF version):
The signature of the function
link_to()
causes$parameters
variable to be treated as a string and PHPUnit gives the following error:Signature of the function
line where error occurs
I am not sure if this error occurs due to a configuration flag in my PHP installation (using 5.5.1), but it can be fixed by either using
$parameters = array()
or$parameters = []
for the last argument.