setAudioscrobblerResponse(self::readTestResponse('errorNoUserExists')); $as = $this->getAudioscrobblerService(); $as->set('user', 'foobarfoo'); try { $response = $as->userGetProfileInformation(); $this->fail('Expected Zend_Service_Technorati_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_Service_Technorati_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) { return file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . $file); } }