Request data desappearing on Integration Test

Hello guys.

I`m writing an Integration test to test my API’s controller, but the post’ed data disappears and becomes nothing inside the controller.

Controller’s method

public function login()
{

    if (empty($this->request->data['email']) || empty($this->request->data['pass'])) {
        throw new \Cake\Network\Exception\BadRequestException('Please fill you username and password.');
    }

    $user = $this->Users->login($this->request->data['email'], $this->request->data['pass']);

    if (empty($user)) {
        throw new \Cake\Network\Exception\UnauthorizedException('There`s no such user');
    }

    $this->set(compact('user'));
}

And my test is like this

public function testLogin()
{

    $data = [
        'email' => 'hey@jude.com',
        'pass' => 'pass'
    ];

    $this->post('/login', $data);

    $this->assertResponseOk();

}

It’s failling because $this->request->data is empty.

The curious thing here is that at the controllers initialize method, $this->request->data is correctly filled. But inside the actual action, it’s empty.

I’m digging and digging to find out where is it being erased, but no success until now.
Any tips?

Thanks!

Have you tried removing any components/middleware that are attached to see if any of those are modifying the request? Also check any beforeFilter() methods on your controllers.