public function testDataSourceDoctrineCollection() { $grid = new Datagrid(); $this->assertFalse($grid->hasDataSource()); $coll = $this->getMock('Doctrine\\Common\\Collections\\ArrayCollection', [], [], '', false); $em = $this->getMock('Doctrine\\ORM\\EntityManager', [], [], '', false); $grid->setDataSource($coll, $em); $this->assertTrue($grid->hasDataSource()); $this->assertInstanceOf('ZfcDatagrid\\DataSource\\Doctrine2Collection', $grid->getDataSource()); $this->setExpectedException('InvalidArgumentException', 'If providing a Collection, also the Doctrine\\ORM\\EntityManager is needed as a second parameter'); $grid->setDataSource($coll); }