domElement = self::getTestFileElementAsDom('TestAuthor.xml', '//author'); } public function testConstruct() { $this->_testConstruct('Zend_Service_Technorati_Author', array($this->domElement)); } public function testConstructThrowsExceptionWithInvalidDom() { $this->_testConstructThrowsExceptionWithInvalidDom('Zend_Service_Technorati_Author', 'DOMElement'); } public function testAuthor() { $author = new Zend_Service_Technorati_Author($this->domElement); $this->assertTrue(is_string($author->getFirstName())); $this->assertEquals('Cesare', $author->getFirstName()); $this->assertTrue(is_string($author->getLastName())); $this->assertEquals('Lamanna', $author->getLastName()); $this->assertTrue(is_string($author->getUsername())); $this->assertEquals('cesarehtml', $author->getUsername()); $this->assertTrue(is_string($author->getDescription())); $this->assertEquals('This is a description.', $author->getDescription()); $this->assertTrue(is_string($author->getFirstName())); $this->assertEquals('This is a bio.', $author->getBio()); $this->assertTrue($author->getThumbnailPicture() instanceof Zend_Uri_Http); $this->assertEquals(Zend_Uri::factory('http://static.technorati.com/progimages/photo.jpg?uid=117217'), $author->getThumbnailPicture()); } public function testSetGet() { $author = new Zend_Service_Technorati_Author($this->domElement); // check first name $set = 'first'; $get = $author->setFirstName($set)->getFirstName(); $this->assertTrue(is_string($get)); $this->assertEquals($set, $get); // check last name $set = 'last'; $get = $author->setLastName($set)->getLastName(); $this->assertTrue(is_string($get)); $this->assertEquals($set, $get); // check username $set = 'user'; $get = $author->setUsername($set)->getUsername(); $this->assertTrue(is_string($get)); $this->assertEquals($set, $get); // check description $set = 'desc'; $get = $author->setUsername($set)->getUsername(); $this->assertTrue(is_string($get)); $this->assertEquals($set, $get); // check bio $set = 'biography'; $get = $author->setBio($set)->getBio(); $this->assertTrue(is_string($get)); $this->assertEquals($set, $get); // check thubmnail picture $set = Zend_Uri::factory('http://www.simonecarletti.com/'); $get = $author->setThumbnailPicture($set)->getThumbnailPicture(); $this->assertTrue($get instanceof Zend_Uri_Http); $this->assertEquals($set, $get); $set = 'http://www.simonecarletti.com/'; $get = $author->setThumbnailPicture($set)->getThumbnailPicture(); $this->assertTrue($get instanceof Zend_Uri_Http); $this->assertEquals(Zend_Uri::factory($set), $get); $set = 'http:::/foo'; try { $author->setThumbnailPicture($set); $this->fail('Expected Zend_Service_Technorati_Exception not thrown'); } catch(Zend_Service_Technorati_Exception $e) { $this->assertContains("Invalid URI", $e->getMessage()); } } }