Crud\Test\TestCase\Action\EditActionTest::testActionPostErrorSave PHP Method

testActionPostErrorSave() public method

Test POST with unsuccessful save()
public testActionPostErrorSave ( ) : void
return void
    public function testActionPostErrorSave()
    {
        $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('Could not update blog', ['element' => 'default', 'params' => ['class' => 'message error', 'original' => 'Could not update blog'], 'key' => 'flash']);
            $this->_subscribeToEvents($this->_controller);
            $this->_controller->Blogs = $this->getMockForModel($this->tableClass, ['save'], ['alias' => 'Blogs', 'table' => 'blogs']);
            $this->_controller->Blogs->expects($this->once())->method('save')->will($this->returnValue(false));
        });
        $this->put('/blogs/edit/1', ['name' => 'Hello World', 'body' => 'Pretty hot body']);
        $this->assertEvents(['beforeFind', 'afterFind', 'beforeSave', 'afterSave', 'setFlash', 'beforeRender']);
        $this->assertFalse($this->_subject->success);
        $this->assertFalse($this->_subject->created);
    }