dimanche 26 avril 2015

Can't send POST data while testing route in Laravel

I'm testing a route in my app which needs to be requested by POST method. I want to send some data along with my request but terminal shows an error :

PHP Test Class :

class UserTest extends TestCase{

    public function testStore(){
        /*
         * Test when first name is empty
         */
        $data = array(
            "fname"                     => "",
            "lname"                     => "",
            "gender"                    => "m",
            "email"                     => "example@gmail.com",
            "cell"                      => "09121234567",
            "password"                  => "rectonic1370",
            "password_confirmation"     => "rectonic1370"
        );
        $response = $this->call('POST', 'doctors', $data);
        $this->assertResponseStatus(\Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST);
        json_decode($response);
        $this->assertTrue((json_last_error() == JSON_ERROR_NONE));
    }
}

Terminal Error :

C:\xampp\htdocs>phpunit
PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from C:\xampp\htdocs\phpunit.xml

A problem occurred //this is the ERROR

PHPUnit.xml :

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="bootstrap/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false"
>
    <testsuites>
        <testsuite name="Application Test Suite">
            <directory>./app/tests/</directory>
        </testsuite>
    </testsuites>
</phpunit>

What's the cause?

Thanks for your help.

Aucun commentaire:

Enregistrer un commentaire