Crud\Test\TestCase\Action\AddActionTest::testActionPostWithEditRedirect PHP Method

testActionPostWithEditRedirect() public method

Test POST will create a record and redirect to /blogs/edit/$id if _POST['_edit'] is present
    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');
    }