/** * @covers CountryService::searchCountries * @expectedException ServiceException */ public function testSearchCountries_WithException() { $searchParams = array('sampleParam1' => 'sampleValue1', 'sampleParam2' => 'sampleValue2'); $countryDaoMock = $this->getMock('CountryDao', array('searchCountries')); $countryDaoMock->expects($this->once())->method('searchCountries')->will($this->throwException(new DaoException())); $this->service->setCountryDao($countryDaoMock); $this->service->searchCountries($searchParams); }