| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: migrate_api.test,v 1.1.2.4 2009/09/22 20:03:56 mikeryan Exp $ 3 /** 4 * @file 5 * Tests for the Migrate API. 6 */ 7 8 /** 9 * API tests for the Migrate module 10 * 11 */ 12 class MigrateUnitTest extends DrupalWebTestCase { 13 function getInfo() { 14 return array( 15 'name' => t('Migrate API'), 16 'description' => t('Test Migrate API functions'), 17 'group' => t('Migrate'), 18 ); 19 } 20 21 function setUp() { 22 // Somehow, we're running in E_STRICT, and Views generates notices. 23 error_reporting(E_ALL & ~E_NOTICE); 24 parent::setUp('views', 'schema', 'tw', 'migrate'); 25 26 // Create and login user 27 $migrate_user = $this->drupalCreateUser(array(MIGRATE_ACCESS_ADVANCED)); 28 $this->drupalLogin($migrate_user); 29 } 30 31 function tearDown() { 32 parent::tearDown(); 33 } 34 35 /** 36 * Test API for managing content sets 37 */ 38 function testCRUD() { 39 // Create test table 40 $ret = array(); 41 $schema = array( 42 'fields' => array( 43 'id' => array( 44 'type' => 'serial', 45 'unsigned' => TRUE, 46 'not null' => TRUE, 47 ), 48 'title' => array( 49 'type' => 'varchar', 50 'length' => 255, 51 'not null' => TRUE, 52 ), 53 'body' => array( 54 'type' => 'varchar', 55 'length' => 255, 56 'not null' => TRUE, 57 ), 58 ), 59 'primary key' => array('id'), 60 ); 61 $tablename = 'migrate_simpletest_sample'; 62 db_create_table($ret, $tablename, $schema); 63 $sql = "INSERT INTO {" . $tablename . "} (title, body) VALUES('%s', '%s')"; 64 db_query($sql, 'Title 1', 'This is a body'); 65 db_query($sql, 'Title 2', 'This is another body'); 66 db_query($sql, 'Title 3', 'This is yet another body'); 67 68 // Creates default view '$tablename' 69 tw_add_tables($tablename); 70 71 // migrate_save_content_set() cases to test: 72 // Int vs. serial vs. string key 73 // Changing key 74 // Array vs. object parameter 75 // New vs. updated content set 76 // External database 77 // Passing explicit base_table/base_database options 78 $content_set = new stdClass; 79 $content_set->view_name = $tablename; 80 $content_set->sourcekey = 'id'; 81 $content_set->contenttype = 'node'; 82 $content_set->desttype = 'page'; 83 $content_set->description = 'Node test'; 84 $content_set->weight = 3; 85 $content_set->lastimported = NULL; 86 $mcsid = migrate_save_content_set($content_set, array('base_table' => $tablename)); 87 if ($this->assertTrue($mcsid, t('Create simple page content set'))) { 88 $row = db_fetch_object(db_query("SELECT * FROM {migrate_content_sets} WHERE mcsid=%d", $mcsid)); 89 if (!$this->assertEqual($row, $content_set, t('Content set data matches'))) { 90 $this->error('row: '.print_r($row, TRUE)); 91 $this->error('content_set: '.print_r($content_set, TRUE)); 92 } 93 $sourceidschema = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE); 94 $maptablename = migrate_map_table_name($mcsid); 95 if ($this->assertTrue(db_table_exists($maptablename), t('Map table exists'))) { 96 $mapschema = _migrate_map_table_schema($sourceidschema); 97 $mapschema['name'] = $maptablename; 98 $info = schema_compare_table($mapschema); 99 if (!$this->assertEqual($info['status'], 'same', t('Map table schema matches'))) { 100 $this->error('Comparison returned: '.print_r($info, TRUE)); 101 } 102 } 103 $msgtablename = migrate_message_table_name($mcsid); 104 if ($this->assertTrue(db_table_exists($msgtablename), t('Message table exists'))) { 105 $msgschema = _migrate_message_table_schema($sourceidschema); 106 $msgschema['name'] = $msgtablename; 107 $info = schema_compare_table($msgschema); 108 if (!$this->assertEqual($info['status'], 'same', t('Message table schema matches'))) { 109 $this->error('Comparison returned: '.print_r($info, TRUE)); 110 } 111 } 112 } 113 114 // migrate_save_content_mapping(), migrate_delete_content_set(), 115 // migrate_delete_content_mapping() 116 } 117 118 /** 119 * Test actual processing of content sets 120 * 121 122 function testProcess() { 123 // migrate_content_process_clear(), migrate_content_process_import(), 124 // migrate_content_process_all() 125 }*/ 126 127 /** 128 * Test hooks 129 130 function testHooks() { 131 // hook_migrate_types, hook_migrate_fields_<type>, hook_migrate_delete_<type>, 132 // hook_migrate_import_<type>, hook_migrate_xlat_<type> 133 }*/ 134 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |