public function testApiCreate($method)
{
$this->_eventManager->on('Dispatcher.invokeController', ['priority' => 1000], function ($event) {
$this->_controller->Flash = $this->getMockBuilder('Cake\\Controller\\Component\\FlashComponent')->setMethods(['set'])->disableOriginalConstructor()->getMock();
$this->_controller->Flash->expects($this->never())->method('set');
$this->_subscribeToEvents($this->_controller);
$this->_controller->Crud->addListener('api', 'Crud.Api');
$this->_controller->RequestHandler->ext = 'json';
});
$this->{$method}('/blogs/add.json', ['name' => '6th blog post', 'body' => 'Amazing blog post']);
$this->assertEvents(['beforeSave', 'afterSave', 'setFlash', 'beforeRedirect']);
$this->assertTrue($this->_subject->success);
$this->assertTrue($this->_subject->created);
$this->assertEquals(['success' => true, 'data' => ['id' => 6]], json_decode($this->_response->body(), true));
}