setAudioscrobblerResponse(self::readTestResponse('errorNoUserExists')); $as = $this->getAudioscrobblerService(); $as->set('user', 'foobarfoo'); try { $response = $as->userGetProfileInformation(); $this->fail('Expected Zend_Http_Client_Exception not thrown'); } catch(Zend_Http_Client_Exception $e) { $this->assertContains("No user exists with this name", $e->getMessage()); } } public function testRequestThrowsHttpClientExceptionWithoutSuccessfulResponse() { $this->setAudioscrobblerResponse(self::readTestResponse('errorResponseStatusError')); $as = $this->getAudioscrobblerService(); $as->set('user', 'foobarfoo'); try { $response = $as->userGetProfileInformation(); $this->fail('Expected Zend_Http_Client_Exception not thrown'); } catch(Zend_Http_Client_Exception $e) { $this->assertContains("404", $e->getMessage()); } } /** * @group ZF-4509 */ public function testSetViaCallIntercept() { $as = new Zend_Service_Audioscrobbler(); $as->setUser("foobar"); $as->setAlbum("Baz"); $this->assertEquals("foobar", $as->get("user")); $this->assertEquals("Baz", $as->get("album")); } /** * @group ZF-6251 */ public function testUnknownMethodViaCallInterceptThrowsException() { $this->setExpectedException("Zend_Service_Exception"); $as = new Zend_Service_Audioscrobbler(); $as->someInvalidMethod(); } /** * @group ZF-6251 */ public function testCallInterceptMethodsRequireExactlyOneParameterAndThrowExceptionOtherwise() { $this->setExpectedException("Zend_Service_Exception"); $as = new Zend_Service_Audioscrobbler(); $as->setUser(); } public static function readTestResponse($file) { $message = file_get_contents(sprintf('%s/_files/%s', dirname(__FILE__), $file)); // Line endings are sometimes an issue inside the canned responses; the // following is a negative lookbehind assertion, and replaces any \n // not preceded by \r with the sequence \r\n, ensuring that the message // is well-formed. return preg_replace("#(?