_tumblr = new Zend_Service_Tumblr(TESTS_ZEND_SERVICE_TUMBLR_EMAIL, TESTS_ZEND_SERVICE_TUMBLR_PASSWORD); } public function testConstructorParameters() { $this->assertEquals(TESTS_ZEND_SERVICE_TUMBLR_EMAIL, $this->_tumblr->getEmail()); $this->assertEquals(TESTS_ZEND_SERVICE_TUMBLR_PASSWORD, $this->_tumblr->getPassword()); } public function testGetHttpClientIsHttpClientDefaultAdapter() { $httpClient = $this->_tumblr->getHttpClient(); $this->assertType('Zend_Http_Client', $httpClient); } public function testCanSetHttpClient() { $httpClient = new Zend_Http_Client(); $this->_tumblr->setHttpClient($httpClient); $this->assertSame($httpClient, $this->_tumblr->getHttpClient()); } public function testHasAuthentication() { $this->assertTrue($this->_tumblr->hasAuthentication()); } public function testDoesNotHaveAuthentication() { $this->_tumblr = new Zend_Service_Tumblr(); $this->assertFalse($this->_tumblr->hasAuthentication()); } public function createNewPostIsValidProvider() { return array( array('Zend_Service_Tumblr_Post_Text', 'text'), array('Zend_Service_Tumblr_Post_Photo', 'photo'), array('Zend_Service_Tumblr_Post_Quote', 'quote') ); } /** * @dataProvider createNewPostIsValidProvider */ public function testCreateNewPostIsValid($postClass, $postType) { $this->assertType($postClass, $this->_tumblr->createNewPost($postType)); } public function testAuthenticateWithValidCredentialsIsValid() { $this->assertTrue($this->_tumblr->authenticate()); } public function testAuthenticateWithInvalidCredentialsIsInvalid() { $this->_tumblr = new Zend_Service_Tumblr('badusername', 'badpassword'); $this->assertFalse($this->_tumblr->authenticate()); } public function testCanGetPostsWithNoOptionsIsValid() { $posts = $this->_tumblr->getPosts(TESTS_ZEND_SERVICE_TUMBLR_TUMBLELOG_URL); $this->assertType('array', $posts); $this->assertTrue(count($posts) > 0); foreach($posts as $post){ $this->assertType('Zend_Service_Tumblr_Post_Abstract', $post); $this->assertType('numeric', $post->getId()); } } public function testCanGetPostsWithStartOptionIsValid() { $posts = $this->_tumblr->getPosts(TESTS_ZEND_SERVICE_TUMBLR_TUMBLELOG_URL, array('start' => 1)); //skip one post $this->assertType('array', $posts); $this->assertTrue(count($posts) > 0); foreach($posts as $post){ $this->assertType('Zend_Service_Tumblr_Post_Abstract', $post); $this->assertType('numeric', $post->getId()); } } public function testCanGetPostsWithNumOptionEqualSetToOneIsValid() { $num = 1; $posts = $this->_tumblr->getPosts(TESTS_ZEND_SERVICE_TUMBLR_TUMBLELOG_URL, array('num' => $num)); //only one post $this->assertType('array', $posts); $this->assertEquals($num, count($posts)); $post = current($posts); $this->assertType('Zend_Service_Tumblr_Post_Abstract', $post); $this->assertType('numeric', $post->getId()); } public function testCanGetPostsWithTypeOptionSetToTextIsValid() { $posts = $this->_tumblr->getPosts(TESTS_ZEND_SERVICE_TUMBLR_TUMBLELOG_URL, array('type' => 'text')); //skip one post $this->assertType('array', $posts); $this->assertTrue(count($posts) > 0); foreach($posts as $post){ $this->assertType('Zend_Service_Tumblr_Post_Text', $post); $this->assertType('numeric', $post->getId()); } } public function testCanGetPostsWithFilterOptionSetToTextIsValid() { } }