| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: image_import.test,v 1.3 2009/08/08 13:32:54 joachim Exp $ 3 4 class ImageImportTest extends DrupalTestCase { 5 6 7 function get_info() { 8 return array('name' => t('Image Import tests'), 'desc' => t('Test Image Import module functionality.'), 'group' => 'Image'); 9 } 10 11 function setUp() { 12 parent::setUp(); 13 14 // Set an image import patch. 15 $image_import_path = file_directory_path() . '/' . $this->randomName(); 16 file_check_directory($image_import_path, FILE_CREATE_DIRECTORY); 17 $this->drupalVariableSet('image_import_path', $image_import_path); 18 19 // User to create image galleries. 20 $this->web_user = $this->drupalCreateUserRolePerm(array('create images', 'view original images', 'edit own images', 'edit any images', 'administer image galleries', 'import images')); 21 $this->drupalGet('logout'); 22 $this->drupalLoginUser($this->web_user); 23 } 24 25 26 function testImport() { 27 // Get 10 random images from 'misc' directory. 28 $images_count = 10; 29 $images_misc = file_scan_directory('misc', '.png'); 30 shuffle($images_misc); 31 $images = array_slice($images_misc, 0, $images_count); 32 33 $image_prefix = $this->randomName(); 34 $edit = array(); 35 $i = 1; 36 foreach ($images as $image) { 37 // Copy each image to import directory with random names. 38 file_copy($image->filename, variable_get('image_import_path', '') . '/' . $image_prefix . $image->basename); 39 $edit['import_file['. $i .']'] = $i; 40 $edit['title['. $i .']'] = $image_prefix . $image->basename; 41 $edit['body['. $i .']'] = $image_prefix . $image->basename; 42 $i++; 43 } 44 $this->drupalPost('admin/content/image_import', $edit, 'Import'); 45 $this->assertWantedRaw('Successfully imported', 'Successfully imported. %s'); 46 47 // Check each image is a node now. 48 foreach ($images as $image) { 49 $node = node_load(array('title' => $image_prefix . $image->basename)); 50 $this->assertTrue($node, 'Image '. $image_prefix . $image->basename .' successfully imported. %s'); 51 } 52 // @todo import into a gallery. 53 } 54 55 function tearDown() { 56 @rmdir(variable_get('image_import_path', '')); 57 58 parent::tearDown(); 59 } 60 }
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 |