public function testFetchItem() { $data = [1 => 'test']; $statementMock = $this->getMock('Zend_Db_Statement_Pdo', ['fetch'], [], '', false); $statementMock->expects($this->once())->method('fetch')->will($this->returnValue($data)); $this->adapterMock->expects($this->once())->method('query')->with($this->selectMock, $this->anything())->will($this->returnValue($statementMock)); $objectMock = $this->getMock('Magento\\Framework\\Object', ['setData'], []); $objectMock->expects($this->once())->method('setData')->with($data); $this->entityFactoryMock->expects($this->once())->method('create')->with('Magento\\Review\\Model\\Review\\Summary')->will($this->returnValue($objectMock)); $item = $this->collection->fetchItem(); $this->assertEquals($objectMock, $item); $this->assertEquals('primary_id', $item->getIdFieldName()); }