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

testActionPostWithAddRedirect() public method

Test POST will create a record and redirect to /blogs/add again if _POST['_add'] is present
    public function testActionPostWithAddRedirect()
    {
        $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', '_add' => 1]);
        $this->assertEvents(['beforeSave', 'afterSave', 'setFlash', 'beforeRedirect']);
        $this->assertTrue($this->_subject->success);
        $this->assertTrue($this->_subject->created);
        $this->assertRedirect('/blogs/add');
    }