markTestSkipped('Twitter tests are not enabled'); return; } $this->twitter = new Zend_Service_Twitter_Search(); } public function testSetResponseTypeToJSON() { $this->twitter->setResponseType('json'); $this->assertEquals('json', $this->twitter->getResponseType()); } public function testSetResponseTypeToATOM() { $this->twitter->setResponseType('atom'); $this->assertEquals('atom', $this->twitter->getResponseType()); } public function testInvalidResponseTypeShouldThrowException() { try { $this->twitter->setResponseType('xml'); $this->fail('Setting an invalid response type should throw an exception'); } catch(Exception $e) { } } public function testValidResponseTypeShouldNotThrowException() { try { $this->twitter->setResponseType('atom'); } catch(Exception $e) { $this->fail('Setting a valid response type should not throw an exception'); } } public function testSearchTrendsReturnsArray() { $response = $this->twitter->trends(); $this->assertType('array', $response); } public function testJsonSearchContainsWordReturnsArray() { $this->twitter->setResponseType('json'); $response = $this->twitter->search('zend'); $this->assertType('array', $response); } public function testAtomSearchContainsWordReturnsObject() { $this->twitter->setResponseType('atom'); $response = $this->twitter->search('zend'); $this->assertTrue($response instanceof Zend_Feed_Atom); } public function testJsonSearchRestrictsLanguageReturnsArray() { $this->twitter->setResponseType('json'); $response = $this->twitter->search('zend', array('lang' => 'de')); $this->assertType('array', $response); $this->assertTrue((isset($response['results'][0]) && $response['results'][0]['iso_language_code'] == "de")); } public function testAtomSearchRestrictsLanguageReturnsObject() { $this->twitter->setResponseType('atom'); /* @var $response Zend_Feed_Atom */ $response = $this->twitter->search('zend', array('lang' => 'de')); $this->assertTrue($response instanceof Zend_Feed_Atom); $this->assertTrue((strpos($response->link('self'), 'lang=de') !== false)); } public function testJsonSearchReturnThirtyResultsReturnsArray() { $this->twitter->setResponseType('json'); $response = $this->twitter->search('zend', array('rpp' => '30')); $this->assertType('array', $response); $this->assertTrue((count($response['results']) == 30)); } public function testAtomSearchReturnThirtyResultsReturnsObject() { $this->twitter->setResponseType('atom'); /* @var $response Zend_Feed_Atom */ $response = $this->twitter->search('zend', array('rpp' => '30')); $this->assertTrue($response instanceof Zend_Feed_Atom); $this->assertTrue(($response->count() == 30)); } public function testAtomSearchShowUserReturnsObject() { $this->twitter->setResponseType('atom'); /* @var $response Zend_Feed_Atom */ $response = $this->twitter->search('zend', array('show_user' => 'true')); $this->assertTrue($response instanceof Zend_Feed_Atom); } } if (PHPUnit_MAIN_METHOD == 'Zend_Service_TwitterSearchTest::main') { Zend_Service_TwitterSearchTest::main(); }