public testActionPostWithEditRedirect ( ) : void | ||
return | void |
public function testActionPostWithEditRedirect()
{
$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->once())->method('set')->with('Successfully created blog', ['element' => 'default', 'params' => ['class' => 'message success', 'original' => 'Successfully created blog'], 'key' => 'flash']);
$this->_subscribeToEvents($this->_controller);
});
$this->post('/blogs/add', ['name' => 'Hello World', 'body' => 'Pretty hot body', '_edit' => 1]);
$this->assertEvents(['beforeSave', 'afterSave', 'setFlash', 'beforeRedirect']);
$this->assertTrue($this->_subject->success);
$this->assertTrue($this->_subject->created);
$this->assertRedirect('/blogs/edit/6');
}