You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$app->get('/say-hello',function() use ($app){
$name = $app->request->params()['name'];
if (is_null($name)){
echo "Hello John Doe!";
} else {
echo "Hello ".$name."!";
}
Trying http://slim-api.com/say-hello from a browser echos Hello John Doe!
Trying http://slim-api.com/say-hello?name=Craig echos Hello Craig! respectively.
So, here's the test for it:
public function testSayHello()
{
$parameters = array('name'=>'Craig Davis');
$this->get('/say-hello',$parameters);
$this->assertEquals(200, $this->response->status());
$this->assertSame("Hello Craig Davis!",$this->response->body());
}
This test fails:
oris@oris:~/slim-api$ phpunit tests/MyTest.php
PHPUnit 3.7.29 by Sebastian Bergmann.
Configuration read from /home/oris/slim-api/phpunit.xml
F
Time: 31 ms, Memory: 5.00Mb
There was 1 failure:
1) MyTest::testSayHello
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-Hello Craig Davis!
+Hello John Doe!
/home/oris/slim-api/tests/MyTest.php:31
/usr/share/php/PHPUnit/TextUI/Command.php:192
/usr/share/php/PHPUnit/TextUI/Command.php:130
FAILURES!
Tests: 1, Assertions: 2, Failures: 1.
Also, consider my addition to your tests/bootstrap.php updating the request globals. (As written in issue #3 ) Maybe we need to improve it somehow?
The text was updated successfully, but these errors were encountered:
Thanks for taking the time to keep me updated for this, much appreciated. I think this should solve the issue you were having, let me know if it doesn't. I'll look at issue 3 next.
Hi,
Consider this route:
Trying
http://slim-api.com/say-hello
from a browser echosHello John Doe!
Trying
http://slim-api.com/say-hello?name=Craig
echosHello Craig!
respectively.So, here's the test for it:
This test fails:
Also, consider my addition to your
tests/bootstrap.php
updating the request globals. (As written in issue #3 ) Maybe we need to improve it somehow?The text was updated successfully, but these errors were encountered: