Crud\Test\TestCase\Action\DeleteActionTest::testStopDelete PHP Method

testStopDelete() public method

Test the flow when the beforeDelete event is stopped
public testStopDelete ( ) : void
return void
    public function testStopDelete()
    {
        $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 delete blog', ['element' => 'default', 'params' => ['class' => 'message error', 'original' => 'Could not delete blog'], 'key' => 'flash']);
            $this->_subscribeToEvents($this->_controller);
            $this->_controller->Crud->on('beforeDelete', function ($event) {
                $event->stopPropagation();
            });
            $this->_controller->Blogs = $this->getMockForModel($this->tableClass, ['delete'], ['alias' => 'Blogs', 'table' => 'blogs']);
            $this->_controller->Blogs->expects($this->never())->method('delete');
        });
        $this->post('/blogs/delete/1');
        $this->assertEvents(['beforeFind', 'afterFind', 'beforeDelete', 'setFlash', 'beforeRedirect']);
        $this->assertFalse($this->_subject->success);
        $this->assertRedirect('/blogs');
    }