yoyoma
yoyoma

Reputation: 3536

'Cake\View\Exception\MissingTemplateException' with phpunit

When I test my REST APIs using an app like Postman, it works fine.

However when I run phpunit I'm getting error

exception 'Cake\View\Exception\MissingTemplateException' with message 'Template file "Addresses/json/add.ctp" is missing.'

In AppController

$this->RequestHandler->renderAs($this, 'json');

Routes

$routes->extensions(['json']);
$routes->resources('Addresses');

ControllerTest simply

$this->post('/addresses/');

Being that it is 100% API, I have no need for any views.

Upvotes: 0

Views: 1297

Answers (1)

yoyoma
yoyoma

Reputation: 3536

FYI I had forgotten to add the serialize

$this->set('_serialize', ['data' => 'data']);

Upvotes: 1

Related Questions