protected function getChannel() { $host = sfContext::getInstance()->getRequest()->getHost(); $serverName = opPluginChannelServerToolkit::getConfig('server_name', str_replace(':80', '', $host)); $browser = new opBrowser($serverName); $browser->get('/channel.xml'); $channel = new PEAR_ChannelFile(); $channel->fromXmlString($browser->getResponse()->getContent()); $channel->setName($serverName); return $channel; }
$app = 'api'; include_once dirname(__FILE__) . '/../../bootstrap/unit.php'; include_once dirname(__FILE__) . '/../../bootstrap/database.php'; $configuration = ProjectConfiguration::getApplicationConfiguration('api', 'test', isset($debug) ? $debug : true); sfContext::createInstance($configuration); $numOfTest = 42; $t = new lime_test($numOfTest, new lime_output_color()); $browser = new opBrowser(); /************************ * Test apiKey Response (5) ************************/ Doctrine::getTable('SnsConfig')->set('enable_jsonapi', false); $member1ApiKey = Doctrine::getTable('Member')->find(1)->getApiKey(); $browser->get('/activity/search.json'); $t->is($browser->getResponse()->getStatusCode(), 404, '[apiKey] JSON API is not enabled.'); Doctrine::getTable('SnsConfig')->set('enable_jsonapi', true); $browser->get('/activity/search.json'); $t->is($browser->getResponse()->getStatusCode(), 401, '[apiKey] apiKey not specified'); $browser->get('/activity/search.json', array('apiKey' => '')); $t->is($browser->getResponse()->getStatusCode(), 401, '[apiKey] empty apiKey'); $browser->get('/activity/search.json', array('apiKey' => 'aaaaaaaaaa')); $t->is($browser->getResponse()->getStatusCode(), 401, '[apiKey] invalid apiKey'); $browser->get('/activity/search.json', array('apiKey' => $member1ApiKey)); $t->is($browser->getResponse()->getStatusCode(), 200, '[apiKey] valid apiKey'); /**************************** * Test activity/search.json (10) ***************************/ $browser->get('/activity/search.json', array('apiKey' => $member1ApiKey)); $t->is($browser->getResponse()->getStatusCode(), 200, '[activity/search.json] valid request'); $browser->get('/activity/search.json', array('apiKey' => $member1ApiKey, 'target' => 'hoge'));