/** * Tests Category deletion * @test * @depends editCategory */ public function deleteCategory($category_id) { $_POST = array('action' => 'delete', 'category_id' => $category_id, 'task' => 'category'); ob_start(); $this->api_controller->index(); $contents = json_decode(ob_get_clean()); $this->assertEquals(0, $contents->error->code, $contents->error->message); }
/** * Tests fetching of locations by location id */ public function testGetLocationsByLocationId() { // Get a random location $location_id = testutils::get_random_id('location'); // Parameters to submit $_GET = array('task' => 'locations', 'by' => 'locid', 'id' => $location_id); ob_start(); $this->api_controller->index(); $contents = json_decode(ob_get_clean()); $this->assertEquals("0", $contents->error->code); $this->assertEquals($location_id, (int) $contents->payload->locations[0]->location->id); }
public function findInstrumentsBySection(Api_Controller $controller) { $section = $controller->params['section']; if (!isset($section)) { $controller->setError(array("status" => 400, "dev" => "No section supplied", "user" => "No section supplied")); return; } foreach ($this->instruments as $instrument) { $sec = ',' . $section . ','; $insec = ',' . $instrument['section'] . ','; if (strpos(',' . strtolower($section) . ',', ',' . strtolower($instrument['section']) . ',') !== FALSE) { $controller->output[] = $instrument; } } }
function __construct() { parent::__construct(); $this->load->library('vars_lib'); $this->upload_config = $this->vars_lib->variable['upload']; $this->api_config = $this->config->item("api"); }
function __construct() { parent::__construct(); $this->load->model('space/member_db', 'member_m'); $this->load->helper('function'); $this->load->helper('common'); }
/** * Test report deletion. * @test * @depends editReport */ public function deleteReport($report_id) { $_POST = array('action' => 'delete', 'incident_id' => $report_id, 'task' => 'reports'); ob_start(); $this->api_controller->index(); $contents = json_decode(ob_get_clean()); $this->assertEquals(0, $contents->error->code, $contents->error->message); }
public function init() { $this->_db = Zend_Registry::get('db'); // If _tableModel is not set, use Zend_Db_Table factory if (null === $this->_tableModel) { $this->_tableModel = new Zend_Db_Table($this->_table); } parent::init(); }
public function before() { parent::before(); $key = Core::request('apikey'); //try normal api key not user if ($key != Core::config('general.api_key')) { $this->_error(__('Wrong Api Key'), 401); } }
public function before() { parent::before(); $key = Core::request('user_token'); //try authenticate the user if ($key == NULL or ($this->user = Auth::instance()->api_login($key)) == FALSE) { $this->_error(__('Wrong Api User Token'), 401); } }
function performance() { global $time, $mem; // Logにパフォーマンス情報を書き込む $action = Api_Controller::getInstance()->getCurrentActionName(); $logger = Api_Controller::getInstance()->getBackend()->getLogger(); $logger->begin(); $logger->log(LOG_INFO, $action . ': peak memory: ' . memory_get_peak_usage() / 1024 / 1024 . 'Mb' . ': diff memory: ' . (memory_get_peak_usage() - $mem) / 1024 / 1024 . 'Mb' . ': ececute time: ' . (microtime(true) - $time) . 's' . ': timestamp: ' . time()); $logger->end(); }
public function before() { parent::before(); if (Theme::get('premium') != 1) { $this->_error('You need a premium theme to use the API', 401); } $key = Core::request('user_token'); //try authenticate the user if ($key == NULL or ($this->user = Auth::instance()->api_login($key)) == FALSE) { $this->_error(__('Wrong Api User Token'), 401); } }
public function before() { parent::before(); if (Theme::get('premium') != 1) { $this->_error('You need a premium theme to use the API', 401); } $key = Core::request('apikey'); //try normal api key not user if ($key != Core::config('general.api_key')) { $this->_error(__('Wrong Api Key'), 401); } }
function __construct() { parent::__construct(); $this->load->model('ip_white_list_model', 'ip_white_list'); $this->load->model('new7_system_model', 'new7_system'); $this->load->model('api_list_model', 'api_list'); $this->load->model('api_logs_model', 'api_logs'); $this->load->library(array('check', 'result')); $this->_api = $this->input->get('api'); $this->_sys_code = $this->input->get('sys_code'); $this->_timestamp = $this->input->get('timestamp'); $this->_sign = $this->input->get('sign'); }
public function testGetIncidentsByMaxId() { // Get random incident id - it must be active and should not be first record in the table $incident_id = testutils::get_random_id('incident', 'WHERE incident_active = 1 AND id NOT IN(SELECT * FROM (SELECT id from incident where incident_active = 1 ORDER BY id ASC LIMIT 1) as first_id)'); // HTTP GET data $_GET = array('task' => 'incidents', 'by' => 'maxid', 'id' => $incident_id); ob_start(); $this->api_controller->index(); $contents = json_decode(ob_get_clean()); // Test for successful execution $this->assertEquals("0", $contents->error->code); // Get random index for the payload data $index = rand(0, count($contents->payload->incidents) - 1); // Fetched incidents should have an id less than or equal to the search parameter $this->assertLessThanOrEqual($incident_id, (int) $contents->payload->incidents[$index]->incident->incidentid); }
/** * Tests fetching countries by country ID * @test */ public function testGetCountryById() { // Test fetching by ISO code $country = ORM::factory('country', testutils::get_random_id('country')); // Test fetching countries by database id $_GET = array('task' => 'countries', 'by' => 'countryid', 'id' => $country->id); // Fetch the content ob_start(); $this->api_controller->index(); $contents = json_decode(ob_get_clean()); $this->assertEquals($country->id, $contents->payload->countries[0]->country->id); $this->assertEquals(0, (int) $contents->error->code); // Test "No Data Found" // Test using invalid country id $_GET['id'] = 'PL'; ob_start(); $this->api_controller->index(); $contents = json_decode(ob_get_clean()); $this->assertEquals("007", $contents->error->code); }
public function __construct() { parent::__construct(); // Gọi model thao tác với bảng class $this->load->model('class_model'); }
public function __construct() { parent::__construct(); $this->load->model('lecturer_model'); }
function __construct() { parent::__construct(); $this->live_config = $this->config->item("live"); $this->load->model('live/live_programs_model', 'live_programs_m'); }
public function init() { parent::init(); }
function __construct() { parent::__construct(); }
function __construct() { parent::__construct(); $this->live_config = $this->config->item("live"); $this->load->model('space/member_db', 'member_m'); }
public function __construct() { parent::__construct(); // Gọi model thao tác với bảng department $this->load->model('department_model'); }
public function __construct() { parent::__construct(); $this->load->model('stream_model'); $this->load->model('certi_model'); }
function __construct() { parent::__construct(); $this->load->model('video_model', 'video_m'); $this->load->model('space/member_db', 'member_m'); }
public function __construct() { parent::__construct(); $this->load->model('required_forms_model'); }
public function __construct() { parent::__construct(); $this->load->model('form_model'); }
function __construct() { parent::__construct(); $this->code = array("code" => 0, "msg" => "初始化"); $this->url = 'http://test.saiku.com.cn'; }