public function testSetViewModelException() { $grid = new Datagrid(); $grid->getViewModel(); $customView = $this->getMock('Zend\\View\\Model\\ViewModel'); $this->setExpectedException('Exception', 'A viewModel is already set. Did you already called $grid->render() or $grid->getViewModel() before?'); $grid->setViewModel($customView); }