本文整理汇总了PHP中debug_mock类的典型用法代码示例。如果您正苦于以下问题:PHP debug_mock类的具体用法?PHP debug_mock怎么用?PHP debug_mock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了debug_mock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_controller
function test_controller()
{
$controller = $this->object->get_controller();
if (is_a($controller, 'empty_controller')) {
return;
}
$definitions = $controller->get_actions_definitions();
$controller_class = get_class($controller);
$empty_action = new empty_action();
foreach ($definitions as $action => $data) {
if (isset($data['template_path'])) {
$template = new template($data['template_path']);
$this->_check_template($template);
}
if (isset($data['action_path'])) {
debug_mock::expect_never_write('write_error');
$action_obj = action_factory::create($data['action_path']);
$this->assertNotIdentical($action_obj, $empty_action, 'controller: "' . $controller_class . '" action object for action "' . $action . '"not found');
$this->_check_action($action_obj);
}
if (isset($data['action_name'])) {
$this->assertTrue($data['action_name'], 'controller: "' . $controller_class . '" action_name property for action "' . $action . '" is empty - check strings');
}
}
$action = $controller->get_default_action();
$this->assertTrue(isset($definitions[$action]), 'controller: "' . $controller_class . '" default action "' . $action . '" doesnt exist');
}
示例2: _move_tree_across
function _move_tree_across($branches, $mvt, $nodecount)
{
foreach ($branches[0] as $nodeid => $node) {
foreach ($branches[1] as $tnodeid => $tnode) {
if ($nodeid == $tnodeid) {
debug_mock::expect_write_error(NESE_ERROR_RECURSION, array('id' => $nodeid, 'target_id' => $tnodeid));
} else {
$current_source = $this->_tree->get_node($nodeid);
$current_target = $this->_tree->get_node($tnodeid);
if ($current_target['root_id'] == $current_source['root_id'] && ($current_source['l'] <= $current_target['l'] && $current_source['r'] >= $current_target['r'])) {
debug_mock::expect_write_error(NESE_ERROR_RECURSION, array('id' => $nodeid, 'target_id' => $tnodeid));
}
}
if (($ret = $this->_tree->move_tree($nodeid, $tnodeid, $mvt)) === false) {
continue;
}
$mnode = $this->_tree->get_node($ret);
$this->assertEqual($ret, $nodeid, 'Nodeid was not returned as expected');
$this->assertEqual($nodecount, count($this->_tree->get_all_nodes()), 'Node count changed');
$p = $this->_tree->get_parent($nodeid);
if ($mvt == NESE_MOVE_BELOW) {
$this->assertEqual($tnode['id'], $p['id'], 'Move below failed (parent ID)');
}
if ($mnode['id'] != $mnode['root_id']) {
$this->assertEqual($p['id'], $mnode['parent_id'], 'Parent ID is wrong');
}
}
}
}
示例3: test_accessible_by_ids_no_ids
function test_accessible_by_ids_no_ids()
{
$this->_login_user(200, array(100 => 'admins', 110 => 'users'));
debug_mock::expect_write_error('ids array is empty');
$result = $this->object->fetch_accessible_by_ids(array());
$this->assertEqual($result, array());
}
示例4: tally
function tally()
{
$debug =& debug_mock :: instance();
$debug->mock->tally();
$debug->expected_data = array();
}
示例5: test_create_no_such_action
function test_create_no_such_action()
{
debug_mock :: expect_write_error('action not found', array('class_path' => 'no_such_action'));
$c =& action_factory :: create('no_such_action');
$this->assertIsA($c, 'empty_action');
}
示例6: tearDown
function tearDown()
{
debug_mock::tally();
$this->dataspace->reset();
$this->form_action->tally();
$this->request->tally();
$this->response->tally();
}
示例7: test_create
function test_create()
{
$c =& action_factory::create('action');
$this->assertNotNull($c);
debug_mock::expect_write_error('action not found', array('class_path' => 'no_such_action'));
$c =& action_factory::create('no_such_action');
$this->assertNull($c);
}
示例8: test_save_object_access_wrong_action_no_parent_records
function test_save_object_access_wrong_action_no_parent_records()
{
$this->object->setReturnValue('get_id', -1);
$this->parent_object->setReturnValue('get_id', -2);
$this->parent_object->setReturnValue('get_class_id', 10);
$this->parent_object_controller->setReturnValue('determine_action', 'display');
debug_mock::expect_write_error('parent object has no acccess records at all', array('parent_id' => -2));
$this->assertFalse($this->ac->save_object_access($this->object, $this->parent_object));
}
示例9: test_create_complex2
function test_create_complex2()
{
debug_mock::expect_never_write();
$this->_create_node('test');
$this->_create_node('test8');
$this->_create_node('test9');
$this->_create_node('test10');
$this->object->set_parent_node_id($this->parent_node_id);
$this->object->set_identifier('node_test');
$id = $this->object->create();
$this->assertEqual($this->object->get_identifier(), 'test11');
}
示例10: test_create
function test_create()
{
debug_mock::expect_never_write();
$this->object->set_parent_node_id($this->parent_node_id);
$this->object->set_identifier('test_node');
$id = $this->object->create();
$this->assertNotIdentical($id, false, 'create operation failed');
$this->assertEqual($id, $this->object->get_id());
$this->_check_sys_site_object_tree_record();
$this->_check_sys_site_object_record();
$this->_check_sys_class_record();
}
示例11: test_create_complex
function test_create_complex()
{
debug_mock::expect_never_write();
$this->_create_node('10ru1');
$this->_create_node('10ru2');
$this->_create_node('10a1');
$this->_create_node(1000);
$this->object->set_parent_node_id($this->parent_node_id);
$this->object->set_identifier('node_test');
$id = $this->object->create();
$this->assertEqual($this->object->get_identifier(), '10ru3');
}
示例12: test_group
function test_group()
{
$ini =& ini::instance('test.ini', TEST_CASES_DIR, false);
debug_mock::expect_write_notice('unknown block', array('ini' => $ini->file_name(), 'block_name' => 'no_group'));
$this->assertNull($ini->group('no_group'));
$this->assertNotNull($ini->group('default'));
$group = $ini->group('test2');
$this->assertTrue(is_array($group) && sizeof($group) == 3);
$this->assertEqual($group['test1'], 2);
$this->assertEqual($group['test2'], 3);
$this->assertEqual($group['test3'], " #It's just a \"test\"!# ");
}
示例13: test_move_tree
function test_move_tree()
{
$movemodes[] = NESE_MOVE_BEFORE;
$movemodes[] = NESE_MOVE_AFTER;
$movemodes[] = NESE_MOVE_BELOW;
for ($j = 0; $j < count($movemodes); $j++) {
$mvt = $movemodes[$j];
// Build a nice random tree
$rnc = 1;
$depth = 2;
$npl = 2;
$relation_tree = $this->_create_sub_node($rnc, $depth, $npl);
$lastrid = false;
$rootnodes = $this->_tree->get_root_nodes();
$branches = array();
$allnodes1 = $this->_tree->get_all_nodes();
foreach ($rootnodes as $rid => $rootnode) {
if ($lastrid) {
if ($rid == $lastrid) {
debug_mock::expect_write_error(NESE_ERROR_RECURSION);
}
$this->_tree->move_tree($rid, $lastrid, $mvt);
}
$branch = $this->_tree->get_branch($rid);
if (!empty($branch)) {
$branches[] = $branch;
}
if (count($branches) == 2) {
$this->_move_tree_across($branches, $mvt, count($this->_tree->get_all_nodes()));
$branches = array();
}
$lastrid = $rid;
}
$allnodes2 = $this->_tree->get_all_nodes();
// Just make sure that all the nodes are still there
$this->assertFalse(count(array_diff(array_keys($allnodes1), array_keys($allnodes2))), 'Nodes got lost during the move');
}
return true;
}
示例14: test_update_file
function test_update_file()
{
$this->test_create_file();
$obj =& site_object_factory::create('file_object');
$this->db->sql_select('media');
$row = $this->db->fetch_row();
$obj->set_attribute('tmp_file_path', PROJECT_DIR . 'images/2.jpg');
$obj->set_attribute('file_name', 'new_name.jpg');
$obj->set_attribute('mime_type', 'image/jpeg');
debug_mock::expect_write_error('media id not set');
$this->assertFalse($obj->update_file(), __LINE__);
$obj->set_attribute('media_id', $row['id']);
$this->assertTrue($obj->update_file(), __LINE__);
$this->db->sql_select('media');
$arr = $this->db->get_array();
$media_id = $obj->get_attribute('media_id');
$this->assertTrue(is_array($arr), __LINE__);
$this->assertEqual(sizeof($arr), 1, __LINE__);
$this->assertEqual($arr[0]['id'], $media_id, __LINE__);
$this->assertEqual($arr[0]['file_name'], $obj->get_attribute('file_name'), __LINE__);
$this->assertEqual($arr[0]['mime_type'], $obj->get_attribute('mime_type'), __LINE__);
$this->assertTrue(file_exists(MEDIA_DIR . $media_id . '.media'), __LINE__);
$this->assertEqual(filesize(MEDIA_DIR . $media_id . '.media'), filesize($obj->get_attribute('tmp_file_path')), __LINE__);
}
示例15: tearDown
function tearDown()
{
$this->_clean_up();
debug_mock :: tally();
}