Welcome Guest, Not a member yet? Register   Sign In
How can I send JSON When using FeatureTestCase?
#1

(This post was last modified: 08-03-2020, 05:41 PM by cbw0916.)

API Document example

Create member

Code:
POST /members HTTP/1.1
Host: localhost
Content-Type: application/json

{
    "name" : "mike",
    "age" : 30
}

MemberController.php
PHP Code:
<?php
class MemberController extends Controller
{
    function create()
    {
        $data $this->reqest->getJSON();  // <-- parse JSON
        // codes..
    }




In this case, I want to make test function like this
PHP Code:
<?php
class MemberTest extends FeatureTestCase
{
    public function testCreateMember() {
        $body = [
            'name' => 'mike',
            'age' => 30,
        ];
        $result $this->post('member/v2/organs'$body);
        // codes..
    }


It doesn't work.
How can I send JSON when FeatureTestCase ?
Reply


Messages In This Thread
How can I send JSON When using FeatureTestCase? - by cbw0916 - 08-02-2020, 11:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB