Crud\Test\TestCase\Action\LookupActionTest::testGetWithQueryModification PHP Method

testGetWithQueryModification() public method

Tests that the beforeLookup can be used to modify the query
public testGetWithQueryModification ( ) : void
return void
    public function testGetWithQueryModification()
    {
        $this->_eventManager->on('Dispatcher.invokeController', ['priority' => 1000], function () {
            $this->_controller->Crud->on('beforeLookup', function ($event) {
                $event->subject->query->where(['id <' => 2]);
            });
        });
        $expected = ['1' => '1st post'];
        $this->get('/blogs/lookup.json');
        $this->assertNotNull($this->viewVariable('viewVar'));
        $this->assertEquals($expected, $this->viewVariable('blogs')->toArray());
    }