more module updates
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Implements actions for managing books (book.module).
|
||||
*/
|
||||
|
||||
function views_bulk_operations_book_action_info() {
|
||||
$actions = array();
|
||||
if (module_exists('book')) {
|
||||
$actions['views_bulk_operations_move_to_book_action'] = array(
|
||||
'type' => 'node',
|
||||
'label' => t('Move to book'),
|
||||
'configurable' => TRUE,
|
||||
'behavior' => array('changes_property'),
|
||||
);
|
||||
$actions['views_bulk_operations_remove_from_book_action'] = array(
|
||||
'type' => 'node',
|
||||
'label' => t('Remove from book'),
|
||||
'configurable' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
function views_bulk_operations_move_to_book_action_form($context) {
|
||||
$form = array();
|
||||
if (!isset($context['book'])) {
|
||||
$context['book'] = '';
|
||||
}
|
||||
$options = array();
|
||||
$books = book_get_books();
|
||||
foreach ($books as $value) {
|
||||
$options[$value['nid']] = $value['title'];
|
||||
}
|
||||
|
||||
if (empty($options)) {
|
||||
drupal_set_message(t('You have no books.'), 'error');
|
||||
return array();
|
||||
}
|
||||
|
||||
$form['book'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Choose a parent book'),
|
||||
'#options' => $options,
|
||||
'#description' => t('Select the parent book page you wish to move the book page into'),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
function views_bulk_operations_move_to_book_action_submit($form, $form_state) {
|
||||
return array('book' => $form_state['values']['book']);
|
||||
}
|
||||
|
||||
function views_bulk_operations_move_to_book_action($node, $context = array()) {
|
||||
if (isset($context['book'])) {
|
||||
$book_node = node_load($context['book']);
|
||||
$mlid = db_select('menu_links' , 'ml')
|
||||
->condition('ml.link_path' , 'node/' . $node->nid)
|
||||
->fields('ml' , array('mlid'))
|
||||
->execute()
|
||||
->fetchField();
|
||||
$node->book['mlid'] = $mlid;
|
||||
$node->book['bid'] = $book_node->nid;
|
||||
$node->book['plid'] = $book_node->book['mlid'];
|
||||
$node->book['module'] = 'book';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the action 'Remove node from a parent book'
|
||||
*/
|
||||
function views_bulk_operations_remove_from_book_action($node, $context) {
|
||||
$book = $node->book['mlid'];
|
||||
book_node_delete($node);
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* VBO action to cancel user accounts.
|
||||
*/
|
||||
|
||||
function views_bulk_operations_user_cancel_action_info() {
|
||||
return array('views_bulk_operations_user_cancel_action' => array(
|
||||
'type' => 'user',
|
||||
'label' => t('Cancel user account'),
|
||||
'configurable' => TRUE,
|
||||
'behavior' => array('deletes_property'),
|
||||
));
|
||||
}
|
||||
|
||||
function views_bulk_operations_user_cancel_action_form($context) {
|
||||
module_load_include('inc', 'user', 'user.pages');
|
||||
$form['user_cancel_method'] = array(
|
||||
'#type' => 'item',
|
||||
'#title' => t('When cancelling these accounts'),
|
||||
);
|
||||
$form['user_cancel_method'] += user_cancel_methods();
|
||||
// Remove method descriptions.
|
||||
foreach (element_children($form['user_cancel_method']) as $element) {
|
||||
unset($form['user_cancel_method'][$element]['#description']);
|
||||
}
|
||||
$admin_access = user_access('administer users');
|
||||
$default_notify = variable_get('user_mail_status_canceled_notify', FALSE);
|
||||
$form['user_cancel_notify'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Notify user when account is canceled.'),
|
||||
'#default_value' => ($admin_access ? FALSE : $default_notify),
|
||||
'#access' => $admin_access && $default_notify,
|
||||
'#description' => t('When enabled, the user will receive an e-mail notification after the account has been cancelled.'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function views_bulk_operations_user_cancel_action_submit($form, $form_state) {
|
||||
return array(
|
||||
'user_cancel_method' => $form_state['values']['user_cancel_method'],
|
||||
'user_cancel_notify' => $form_state['values']['user_cancel_notify'],
|
||||
);
|
||||
}
|
||||
|
||||
function views_bulk_operations_user_cancel_action($account, $context) {
|
||||
global $user;
|
||||
// Prevent the user from cancelling itself.
|
||||
if ($account->uid == $user->uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow other modules to react on the cancellation.
|
||||
if ($context['user_cancel_method'] != 'user_cancel_delete') {
|
||||
module_invoke_all('user_cancel', array(), $account, $context['user_cancel_method']);
|
||||
}
|
||||
|
||||
switch ($context['user_cancel_method']) {
|
||||
case 'user_cancel_block':
|
||||
case 'user_cancel_block_unpublish':
|
||||
default:
|
||||
// Send account blocked notification if option was checked.
|
||||
if (!empty($context['user_cancel_notify'])) {
|
||||
_user_mail_notify('status_blocked', $account);
|
||||
}
|
||||
user_save($account, array('status' => 0));
|
||||
watchdog('user', 'Blocked user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
|
||||
break;
|
||||
|
||||
case 'user_cancel_reassign':
|
||||
case 'user_cancel_delete':
|
||||
// Send account canceled notification if option was checked.
|
||||
if (!empty($context['user_cancel_notify'])) {
|
||||
_user_mail_notify('status_canceled', $account);
|
||||
}
|
||||
user_delete($account->uid);
|
||||
watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
|
||||
break;
|
||||
}
|
||||
}
|
1
sites/all/modules/contrib/views/views_data_export/.gitignore
vendored
Normal file
1
sites/all/modules/contrib/views/views_data_export/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.DS_Store
|
@@ -0,0 +1,508 @@
|
||||
<?php
|
||||
|
||||
abstract class ViewsDataExportBaseTest extends ViewsTestCase {
|
||||
|
||||
protected function setUp() {
|
||||
$modules = func_get_args();
|
||||
if (isset($modules[0]) && is_array($modules[0])) {
|
||||
$modules = $modules[0];
|
||||
}
|
||||
|
||||
$modules[] = 'views_data_export';
|
||||
$modules[] = 'views_ui';
|
||||
$modules[] = 'views';
|
||||
parent::setUp($modules);
|
||||
|
||||
// Define the schema and views data variable before enabling the test module.
|
||||
variable_set('views_test_schema', $this->schemaDefinition());
|
||||
variable_set('views_test_views_data', $this->viewsData());
|
||||
variable_set('views_test_views_plugins', $this->viewsPlugins());
|
||||
|
||||
module_enable(array('views_test'));
|
||||
$this->resetAll();
|
||||
|
||||
// Load the test dataset.
|
||||
$data_set = $this->dataSet();
|
||||
$query = db_insert('views_test')
|
||||
->fields(array_keys($data_set[0]));
|
||||
foreach ($data_set as $record) {
|
||||
$query->values($record);
|
||||
}
|
||||
$query->execute();
|
||||
$this->checkPermissions(array(), TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function allows to enable views ui from a higher class which can't change the setup function anymore.
|
||||
*
|
||||
* @TODO
|
||||
* Convert existing setUp functions.
|
||||
*/
|
||||
function enableViewsUi() {
|
||||
module_enable(array('views_ui'));
|
||||
// @TODO Figure out why it's required to clear the cache here.
|
||||
views_module_include('views_default', TRUE);
|
||||
views_get_all_views(TRUE);
|
||||
menu_rebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* The schema definition.
|
||||
*/
|
||||
protected function schemaDefinition() {
|
||||
$schema['views_test'] = array(
|
||||
'description' => 'Basic test table for Views tests.',
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => 'serial',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'name' => array(
|
||||
'description' => "A person's name",
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'age' => array(
|
||||
'description' => "The person's age",
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0),
|
||||
'job' => array(
|
||||
'description' => "The person's job",
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => 'Undefined',
|
||||
),
|
||||
'created' => array(
|
||||
'description' => "The creation date of this record",
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
'name' => array('name')
|
||||
),
|
||||
'indexes' => array(
|
||||
'ages' => array('age'),
|
||||
),
|
||||
);
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* The views data definition.
|
||||
*/
|
||||
protected function viewsData() {
|
||||
// Declaration of the base table.
|
||||
$data['views_test']['table'] = array(
|
||||
'group' => t('Views test'),
|
||||
'base' => array(
|
||||
'field' => 'id',
|
||||
'title' => t('Views test'),
|
||||
'help' => t('Users who have created accounts on your site.'),
|
||||
),
|
||||
);
|
||||
|
||||
// Declaration of fields.
|
||||
$data['views_test']['id'] = array(
|
||||
'title' => t('ID'),
|
||||
'help' => t('The test data ID'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
$data['views_test']['name'] = array(
|
||||
'title' => t('Name'),
|
||||
'help' => t('The name of the person'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
$data['views_test']['age'] = array(
|
||||
'title' => t('Age'),
|
||||
'help' => t('The age of the person'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
$data['views_test']['job'] = array(
|
||||
'title' => t('Job'),
|
||||
'help' => t('The job of the person'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
$data['views_test']['created'] = array(
|
||||
'title' => t('Created'),
|
||||
'help' => t('The creation date of this record'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_date',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_date',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function viewsPlugins() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* A very simple test dataset.
|
||||
*/
|
||||
protected function dataSet() {
|
||||
return array(
|
||||
array(
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
'job' => 'Singer',
|
||||
'created' => gmmktime(0, 0, 0, 1, 1, 2000),
|
||||
),
|
||||
array(
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
'job' => 'Singer',
|
||||
'created' => gmmktime(0, 0, 0, 1, 2, 2000),
|
||||
),
|
||||
array(
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
'job' => 'Drummer',
|
||||
'created' => gmmktime(6, 30, 30, 1, 1, 2000),
|
||||
),
|
||||
array(
|
||||
'name' => 'Paul',
|
||||
'age' => 26,
|
||||
'job' => 'Songwriter',
|
||||
'created' => gmmktime(6, 0, 0, 1, 1, 2000),
|
||||
),
|
||||
array(
|
||||
'name' => 'Meredith',
|
||||
'age' => 30,
|
||||
'job' => 'Speaker',
|
||||
'created' => gmmktime(6, 30, 10, 1, 1, 2000),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and return a basic view of the views_test table.
|
||||
*
|
||||
* @return view
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
views_include('view');
|
||||
|
||||
// Create the basic view.
|
||||
$view = new view();
|
||||
$view->vid = 'test_view';
|
||||
$view->add_display('default');
|
||||
$view->base_table = 'views_test';
|
||||
|
||||
// Set up the fields we need.
|
||||
$display = $view->new_display('default', 'Master', 'default');
|
||||
$display->override_option('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
// Set up the sort order.
|
||||
$display->override_option('sorts', array(
|
||||
'id' => array(
|
||||
'order' => 'ASC',
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
// Set up the pager.
|
||||
$display->override_option('pager', array(
|
||||
'type' => 'none',
|
||||
'options' => array('offset' => 0),
|
||||
));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
public function logViewResult($result, $prefix = 'View result:<br>') {
|
||||
$this->verbose($prefix . '<br><pre>' . check_plain($result) .'</pre>');
|
||||
}
|
||||
|
||||
public function assertBatchedExportEqual($path, $expected, $message) {
|
||||
$this->drupalGet($path);
|
||||
$output = $this->drupalGetContent();
|
||||
$this->logViewResult($output);
|
||||
$this->logViewResult($expected, 'Expected result:<br>');
|
||||
$this->assertEqual($this->normaliseString($output), $this->normaliseString($expected), $message);
|
||||
}
|
||||
|
||||
public function assertExportEqual($a, $b, $message) {
|
||||
$this->logViewResult($a);
|
||||
$this->logViewResult($b, 'Expected result:<br>');
|
||||
$this->assertEqual($this->normaliseString($a), $this->normaliseString($b), $message);
|
||||
}
|
||||
|
||||
protected function normaliseString($s) {
|
||||
// Normalize line endings
|
||||
// Convert all line-endings to UNIX format
|
||||
$s = str_replace("\r\n", "\n", $s);
|
||||
$s = str_replace("\r", "\n", $s);
|
||||
$s = trim($s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
abstract class ViewsDataExportSimpleExportTest extends ViewsDataExportBaseTest {
|
||||
|
||||
protected $vde_export_type;
|
||||
|
||||
/**
|
||||
* Tests the non-batched export functionality for this style.
|
||||
*/
|
||||
public function testNonBatchedExport() {
|
||||
$path = 'vde_test/' . $this->randomName();
|
||||
list($view, $expected) = $this->getExportView($path);
|
||||
// Save this view so we can hit the path.
|
||||
$view->save();
|
||||
// Ensure that the menu router system is rebuilt on the next page load.
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
|
||||
$this->drupalGet($path);
|
||||
$result = $this->drupalGetContent();
|
||||
|
||||
$this->assertExportEqual($result, $expected, 'Non batched ' . $this->vde_export_type . ' export matched expected output.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the batched export functionality for this style.
|
||||
*/
|
||||
public function testBatchedExport() {
|
||||
$path = 'vde_test/' . $this->randomName();
|
||||
list($view, $expected) = $this->getExportView($path);
|
||||
$display = &$view->display['vde_test']->handler;
|
||||
// Set this view to be batched.
|
||||
$display->override_option('use_batch', 'batch');
|
||||
// Save this view so we can hit the path.
|
||||
$view->save();
|
||||
// Ensure that the menu router system is rebuilt on the next page load.
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
|
||||
$this->assertBatchedExportEqual($path, $expected, 'Batched ' . $this->vde_export_type . ' export matched expected output.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a very basic view and expected output for this style.
|
||||
*
|
||||
* @return
|
||||
* An array containing two elements:
|
||||
* - A View object, for the export.
|
||||
* - The expected out from that view, if is was executed without further
|
||||
* changes.
|
||||
*/
|
||||
abstract protected function getExportView($path = 'vde_test');
|
||||
|
||||
/**
|
||||
* Build and return a basic view of the views_test table.
|
||||
*
|
||||
* @return view
|
||||
*/
|
||||
protected function getBasicExportView() {
|
||||
views_include('view');
|
||||
|
||||
// Create the basic view.
|
||||
$view = new view();
|
||||
$view->vid = 'new';
|
||||
$view->base_table = 'views_test';
|
||||
|
||||
// Set up the fields we need.
|
||||
$display = $view->new_display('default', 'Master', 'default');
|
||||
|
||||
$display->override_option('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
// Set up the sort order.
|
||||
$display->override_option('sorts', array(
|
||||
'id' => array(
|
||||
'order' => 'ASC',
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
// Set up the pager.
|
||||
$display->override_option('pager', array(
|
||||
'type' => 'none',
|
||||
'options' => array('offset' => 0),
|
||||
));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a view that's our basic view, but with hide if empty/0 support.
|
||||
*
|
||||
* We add this to the 'age' field.
|
||||
*/
|
||||
protected function getHideIfEmptyExportView() {
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->display['default']->handler;
|
||||
|
||||
$display->override_option('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
// Hide their name if its empty.
|
||||
'hide_empty' => TRUE,
|
||||
// But we don't hide it if it's: 0.
|
||||
'empty_zero' => FALSE,
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
// Hide their age if it's empty.
|
||||
'hide_empty' => TRUE,
|
||||
'empty_zero' => TRUE,
|
||||
),
|
||||
));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a given view very simply.
|
||||
*
|
||||
* This will take a view, and add a display plugin of the correct export type,
|
||||
* and then run it and compare it with the expected output.
|
||||
*/
|
||||
protected function executeAndCompareGivenView(view $view, $expected, $message = '', $style_options = array()) {
|
||||
$path = 'vde_test/' . $this->randomName();
|
||||
|
||||
$display = $view->new_display('views_data_export', 'Data export', 'vde_test');
|
||||
$display->override_option('style_plugin', $this->getStylePluginName());
|
||||
$display->override_option('style_options', $style_options);
|
||||
$display->override_option('path', $path);
|
||||
|
||||
// Save this view so we can hit the path.
|
||||
$view->save();
|
||||
|
||||
// Ensure that the menu router system is rebuilt on the next page load.
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
|
||||
$this->drupalGet($path);
|
||||
$result = $this->drupalGetContent();
|
||||
|
||||
$this->assertExportEqual($result, $expected, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the style plugin represented by this test.
|
||||
*/
|
||||
abstract protected function getStylePluginName();
|
||||
}
|
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
class CSVExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
|
||||
|
||||
protected $profile = 'testing';
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'CSV Export',
|
||||
'description' => 'Various tests for exporting to CSV.',
|
||||
'group' => 'Views Data Export',
|
||||
);
|
||||
}
|
||||
|
||||
protected $vde_export_type = 'CSV';
|
||||
|
||||
protected function getStylePluginName() {
|
||||
return 'views_data_export_csv';
|
||||
}
|
||||
|
||||
protected function getExportView($path = 'vde_test') {
|
||||
// Create the basic view.
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->new_display('views_data_export', 'Data export', 'vde_test');
|
||||
$display->override_option('style_plugin', $this->getStylePluginName());
|
||||
$display->override_option('path', $path);
|
||||
|
||||
$expected = '"ID","Name","Age"
|
||||
"1","John","25"
|
||||
"2","George","27"
|
||||
"3","Ringo","28"
|
||||
"4","Paul","26"
|
||||
"5","Meredith","30"';
|
||||
|
||||
return array(&$view, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure that HTML tags are kept in CSV files when requested.
|
||||
*/
|
||||
protected function testKeepHTML() {
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->display['default']->handler;
|
||||
|
||||
$display->override_option('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
// Add a label to include HTML
|
||||
'label' => '<strong id="id">ID</strong>',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
// Alter this field to include HTML.
|
||||
'alter' => array(
|
||||
'alter_text' => TRUE,
|
||||
'text' => '<em>[name]</em>',
|
||||
),
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
$style_options = array(
|
||||
'keep_html' => TRUE,
|
||||
);
|
||||
|
||||
$expected = '"<strong id=""id"">ID</strong>","Name","Age"
|
||||
"1","<em>John</em>","25"
|
||||
"2","<em>George</em>","27"
|
||||
"3","<em>Ringo</em>","28"
|
||||
"4","<em>Paul</em>","26"
|
||||
"5","<em>Meredith</em>","30"';
|
||||
|
||||
$message = 'Keep HTML test in ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message, $style_options);
|
||||
|
||||
|
||||
// And now make sure that HTML tags are stripped correctly.
|
||||
$style_options = array(
|
||||
'keep_html' => FALSE,
|
||||
);
|
||||
|
||||
$expected = '"ID","Name","Age"
|
||||
"1","John","25"
|
||||
"2","George","27"
|
||||
"3","Ringo","28"
|
||||
"4","Paul","26"
|
||||
"5","Meredith","30"';
|
||||
|
||||
$message = 'Keep HTML reverse test in ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message, $style_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure that HTML tags are kept in CSV files when requested.
|
||||
*/
|
||||
protected function testTrimFields() {
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->display['default']->handler;
|
||||
|
||||
$display->override_option('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
'label' => 'ID',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
// Alter this field to include HTML.
|
||||
'alter' => array(
|
||||
'alter_text' => TRUE,
|
||||
'text' => ' [name] ',
|
||||
),
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
$style_options = array(
|
||||
'trim' => FALSE,
|
||||
);
|
||||
|
||||
$expected = '"ID","Name","Age"
|
||||
"1"," John ","25"
|
||||
"2"," George ","27"
|
||||
"3"," Ringo ","28"
|
||||
"4"," Paul ","26"
|
||||
"5"," Meredith ","30"';
|
||||
|
||||
$message = 'Trim reverse test in ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message, $style_options);
|
||||
|
||||
// And now make sure that trimming works as expected.
|
||||
$style_options = array(
|
||||
'trim' => TRUE,
|
||||
);
|
||||
|
||||
$expected = '"ID","Name","Age"
|
||||
"1","John","25"
|
||||
"2","George","27"
|
||||
"3","Ringo","28"
|
||||
"4","Paul","26"
|
||||
"5","Meredith","30"';
|
||||
|
||||
$message = 'Trim test in ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message, $style_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure that Encoding options work.
|
||||
*/
|
||||
protected function testIconvEncoding() {
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
db_update('views_test')
|
||||
->fields(array('name' => 'Jo€hn'))
|
||||
->condition('name', 'John')
|
||||
->execute();
|
||||
|
||||
$encodings = array(
|
||||
'ISO-8859-1//TRANSLIT' => 'EUR',
|
||||
'utf8_decode' => '?',
|
||||
);
|
||||
|
||||
foreach ($encodings as $encoding => $conversion) {
|
||||
|
||||
$style_options = array(
|
||||
'encoding' => $encoding,
|
||||
);
|
||||
|
||||
$expected = '"ID","Name","Age"
|
||||
"1","Jo' . $conversion . 'hn","25"
|
||||
"2","George","27"
|
||||
"3","Ringo","28"
|
||||
"4","Paul","26"
|
||||
"5","Meredith","30"';
|
||||
|
||||
$message = 'Character encoding ' . $encoding . ' worked correctly.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message, $style_options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
class DOCExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
|
||||
|
||||
protected $profile = 'testing';
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'DOC Export',
|
||||
'description' => 'Various tests for exporting to DOC.',
|
||||
'group' => 'Views Data Export',
|
||||
);
|
||||
}
|
||||
|
||||
protected $vde_export_type = 'DOC';
|
||||
|
||||
protected function getStylePluginName() {
|
||||
return 'views_data_export_doc';
|
||||
}
|
||||
|
||||
protected function getExportView($path = 'vde_test') {
|
||||
// Create the basic view.
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->new_display('views_data_export', 'Data export', 'vde_test');
|
||||
$display->override_option('style_plugin', $this->getStylePluginName());
|
||||
$display->override_option('path', $path);
|
||||
|
||||
$expected = '<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<thead><tr><th>ID</th><th>Name</th><th>Age</th></tr></thead> <tbody> <tr class="odd"><td>1</td><td>John</td><td>25</td> </tr>
|
||||
<tr class="even"><td>2</td><td>George</td><td>27</td> </tr>
|
||||
<tr class="odd"><td>3</td><td>Ringo</td><td>28</td> </tr>
|
||||
<tr class="even"><td>4</td><td>Paul</td><td>26</td> </tr>
|
||||
<tr class="odd"><td>5</td><td>Meredith</td><td>30</td> </tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
return array(&$view, $expected);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
class TXTExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
|
||||
|
||||
protected $profile = 'testing';
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'TXT Export',
|
||||
'description' => 'Various tests for exporting to TXT.',
|
||||
'group' => 'Views Data Export',
|
||||
);
|
||||
}
|
||||
|
||||
protected $vde_export_type = 'TXT';
|
||||
|
||||
protected function getStylePluginName() {
|
||||
return 'views_data_export_txt';
|
||||
}
|
||||
|
||||
protected function getExportView($path = 'vde_test') {
|
||||
// Create the basic view.
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->new_display('views_data_export', 'Data export', 'vde_test');
|
||||
$display->override_option('style_plugin', $this->getStylePluginName());
|
||||
$display->override_option('path', $path);
|
||||
|
||||
$expected = '[ID]
|
||||
|
||||
1
|
||||
[Name]
|
||||
|
||||
John
|
||||
[Age]
|
||||
|
||||
25
|
||||
----------------------------------------
|
||||
|
||||
[ID]
|
||||
|
||||
2
|
||||
[Name]
|
||||
|
||||
George
|
||||
[Age]
|
||||
|
||||
27
|
||||
----------------------------------------
|
||||
|
||||
[ID]
|
||||
|
||||
3
|
||||
[Name]
|
||||
|
||||
Ringo
|
||||
[Age]
|
||||
|
||||
28
|
||||
----------------------------------------
|
||||
|
||||
[ID]
|
||||
|
||||
4
|
||||
[Name]
|
||||
|
||||
Paul
|
||||
[Age]
|
||||
|
||||
26
|
||||
----------------------------------------
|
||||
|
||||
[ID]
|
||||
|
||||
5
|
||||
[Name]
|
||||
|
||||
Meredith
|
||||
[Age]
|
||||
|
||||
30
|
||||
----------------------------------------';
|
||||
|
||||
return array(&$view, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to check if empty fields are correctly hidden.
|
||||
*/
|
||||
protected function testHideEmptySupport() {
|
||||
$view = $this->getHideIfEmptyExportView();
|
||||
|
||||
// We need to ensure that the test fields are actually empty/0.
|
||||
db_update('views_test')
|
||||
->fields(array('age' => 0,))
|
||||
->condition('name', 'Paul')
|
||||
->execute();
|
||||
|
||||
db_update('views_test')
|
||||
->fields(array('name' => '',))
|
||||
->condition('name', 'George')
|
||||
->execute();
|
||||
|
||||
db_update('views_test')
|
||||
->fields(array('name' => 0,))
|
||||
->condition('name', 'John')
|
||||
->execute();
|
||||
|
||||
$expected = '[ID]
|
||||
|
||||
1
|
||||
[Name]
|
||||
|
||||
0
|
||||
[Age]
|
||||
|
||||
25
|
||||
----------------------------------------
|
||||
|
||||
[ID]
|
||||
|
||||
2
|
||||
[Age]
|
||||
|
||||
27
|
||||
----------------------------------------
|
||||
|
||||
[ID]
|
||||
|
||||
3
|
||||
[Name]
|
||||
|
||||
Ringo
|
||||
[Age]
|
||||
|
||||
28
|
||||
----------------------------------------
|
||||
|
||||
[ID]
|
||||
|
||||
4
|
||||
[Name]
|
||||
|
||||
Paul
|
||||
----------------------------------------
|
||||
|
||||
[ID]
|
||||
|
||||
5
|
||||
[Name]
|
||||
|
||||
Meredith
|
||||
[Age]
|
||||
|
||||
30
|
||||
----------------------------------------';
|
||||
|
||||
$message = 'Hide if empty support for ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
class XLSExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
|
||||
|
||||
protected $profile = 'testing';
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'XLS Export',
|
||||
'description' => 'Various tests for exporting to XLS.',
|
||||
'group' => 'Views Data Export',
|
||||
);
|
||||
}
|
||||
|
||||
protected $vde_export_type = 'XLS';
|
||||
|
||||
protected function getStylePluginName() {
|
||||
return 'views_data_export_xls';
|
||||
}
|
||||
|
||||
protected function getExportView($path = 'vde_test') {
|
||||
// Create the basic view.
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->new_display('views_data_export', 'Data export', 'vde_test');
|
||||
$display->override_option('style_plugin', $this->getStylePluginName());
|
||||
$display->override_option('path', $path);
|
||||
|
||||
$expected = '<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<thead><tr><th>ID</th><th>Name</th><th>Age</th></tr></thead> <tbody> <tr class="odd"><td>1</td><td>John</td><td>25</td> </tr>
|
||||
<tr class="even"><td>2</td><td>George</td><td>27</td> </tr>
|
||||
<tr class="odd"><td>3</td><td>Ringo</td><td>28</td> </tr>
|
||||
<tr class="even"><td>4</td><td>Paul</td><td>26</td> </tr>
|
||||
<tr class="odd"><td>5</td><td>Meredith</td><td>30</td> </tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
return array(&$view, $expected);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,386 @@
|
||||
<?php
|
||||
|
||||
class XMLExportViewsDataExportTests extends ViewsDataExportSimpleExportTest {
|
||||
|
||||
protected $profile = 'testing';
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'XML Export',
|
||||
'description' => 'Various tests for exporting to XML.',
|
||||
'group' => 'Views Data Export',
|
||||
);
|
||||
}
|
||||
|
||||
protected $vde_export_type = 'XML';
|
||||
|
||||
protected function getStylePluginName() {
|
||||
return 'views_data_export_xml';
|
||||
}
|
||||
|
||||
protected function getExportView($path = 'vde_test') {
|
||||
// Create the basic view.
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->new_display('views_data_export', 'Data export', 'vde_test');
|
||||
$display->override_option('style_plugin', 'views_data_export_xml');
|
||||
$display->override_option('path', $path);
|
||||
|
||||
$expected = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<views_tests>
|
||||
<views_test>
|
||||
<ID>1</ID>
|
||||
<Name>John</Name>
|
||||
<Age>25</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>2</ID>
|
||||
<Name>George</Name>
|
||||
<Age>27</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>3</ID>
|
||||
<Name>Ringo</Name>
|
||||
<Age>28</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>4</ID>
|
||||
<Name>Paul</Name>
|
||||
<Age>26</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>5</ID>
|
||||
<Name>Meredith</Name>
|
||||
<Age>30</Age>
|
||||
</views_test>
|
||||
</views_tests>';
|
||||
|
||||
return array(&$view, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to check if empty fields are correctly hidden.
|
||||
*/
|
||||
protected function testHideEmptySupport() {
|
||||
$view = $this->getHideIfEmptyExportView();
|
||||
|
||||
// We need to ensure that the test fields are actually empty/0.
|
||||
db_update('views_test')
|
||||
->fields(array('age' => 0,))
|
||||
->condition('name', 'Paul')
|
||||
->execute();
|
||||
|
||||
db_update('views_test')
|
||||
->fields(array('name' => '',))
|
||||
->condition('name', 'George')
|
||||
->execute();
|
||||
|
||||
db_update('views_test')
|
||||
->fields(array('name' => 0,))
|
||||
->condition('name', 'John')
|
||||
->execute();
|
||||
|
||||
$expected = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<views_tests>
|
||||
<views_test>
|
||||
<ID>1</ID>
|
||||
<Name>0</Name>
|
||||
<Age>25</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>2</ID>
|
||||
<Age>27</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>3</ID>
|
||||
<Name>Ringo</Name>
|
||||
<Age>28</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>4</ID>
|
||||
<Name>Paul</Name>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>5</ID>
|
||||
<Name>Meredith</Name>
|
||||
<Age>30</Age>
|
||||
</views_test>
|
||||
</views_tests>';
|
||||
|
||||
$message = 'Hide if empty support for ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure that valid XML is produced when someone doesn't specify a label.
|
||||
*/
|
||||
protected function testEmptyLabels() {
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->display['default']->handler;
|
||||
|
||||
$display->override_option('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
// Remove the label from the name field.
|
||||
'label' => '',
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
// Make this label intentially invalid XML.
|
||||
'label' => '.',
|
||||
),
|
||||
));
|
||||
|
||||
$expected = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<views_tests>
|
||||
<views_test>
|
||||
<ID>1</ID>
|
||||
<no-name>John</no-name>
|
||||
<invalid-tag-name>25</invalid-tag-name>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>2</ID>
|
||||
<no-name>George</no-name>
|
||||
<invalid-tag-name>27</invalid-tag-name>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>3</ID>
|
||||
<no-name>Ringo</no-name>
|
||||
<invalid-tag-name>28</invalid-tag-name>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>4</ID>
|
||||
<no-name>Paul</no-name>
|
||||
<invalid-tag-name>26</invalid-tag-name>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID>5</ID>
|
||||
<no-name>Meredith</no-name>
|
||||
<invalid-tag-name>30</invalid-tag-name>
|
||||
</views_test>
|
||||
</views_tests>';
|
||||
|
||||
$message = 'Empty label test in ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure that XML nodes names can be manually specified.
|
||||
*/
|
||||
protected function testCustomiseXMLNodes() {
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
// Load the include that contains the _views_data_export_xml_tag_clean function.
|
||||
module_load_include('inc', 'views_data_export', 'theme/views_data_export.theme');
|
||||
|
||||
|
||||
$root_node = _views_data_export_xml_tag_clean($this->randomName());
|
||||
$item_node = _views_data_export_xml_tag_clean($this->randomName());
|
||||
|
||||
$style_options = array(
|
||||
'root_node' => $root_node,
|
||||
'item_node' => $item_node,
|
||||
);
|
||||
|
||||
$expected = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<' . $root_node . '>
|
||||
<' . $item_node . '>
|
||||
<ID>1</ID>
|
||||
<Name>John</Name>
|
||||
<Age>25</Age>
|
||||
</' . $item_node . '>
|
||||
<' . $item_node . '>
|
||||
<ID>2</ID>
|
||||
<Name>George</Name>
|
||||
<Age>27</Age>
|
||||
</' . $item_node . '>
|
||||
<' . $item_node . '>
|
||||
<ID>3</ID>
|
||||
<Name>Ringo</Name>
|
||||
<Age>28</Age>
|
||||
</' . $item_node . '>
|
||||
<' . $item_node . '>
|
||||
<ID>4</ID>
|
||||
<Name>Paul</Name>
|
||||
<Age>26</Age>
|
||||
</' . $item_node . '>
|
||||
<' . $item_node . '>
|
||||
<ID>5</ID>
|
||||
<Name>Meredith</Name>
|
||||
<Age>30</Age>
|
||||
</' . $item_node . '>
|
||||
</' . $root_node . '>';
|
||||
|
||||
$message = 'Custom XML nodes test in ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message, $style_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure certain fields can be optionally non-escaped.
|
||||
*/
|
||||
protected function testXMLNoEntityEncode() {
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$display = $view->display['default']->handler;
|
||||
|
||||
$style_options = array(
|
||||
'no_entity_encode' => array(
|
||||
'id' => 'id',
|
||||
),
|
||||
);
|
||||
|
||||
$display->override_option('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
'alter' => array(
|
||||
'alter_text' => TRUE,
|
||||
'text' => '<strong>[id]</strong>',
|
||||
),
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
'alter' => array(
|
||||
'alter_text' => TRUE,
|
||||
'text' => '<em>[name]</em>',
|
||||
),
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
$expected = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<views_tests>
|
||||
<views_test>
|
||||
<ID><strong>1</strong></ID>
|
||||
<Name><em>John</em></Name>
|
||||
<Age>25</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID><strong>2</strong></ID>
|
||||
<Name><em>George</em></Name>
|
||||
<Age>27</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID><strong>3</strong></ID>
|
||||
<Name><em>Ringo</em></Name>
|
||||
<Age>28</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID><strong>4</strong></ID>
|
||||
<Name><em>Paul</em></Name>
|
||||
<Age>26</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID><strong>5</strong></ID>
|
||||
<Name><em>Meredith</em></Name>
|
||||
<Age>30</Age>
|
||||
</views_test>
|
||||
</views_tests>';
|
||||
|
||||
$message = 'XML in values test in ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message, $style_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure certain fields can be optionally non-escaped.
|
||||
*/
|
||||
protected function testXMLCDATAWrapper() {
|
||||
$view = $this->getBasicExportView();
|
||||
|
||||
$style_options = array(
|
||||
'cdata_wrapper' => array(
|
||||
'id' => 'id',
|
||||
'name' => 'name',
|
||||
),
|
||||
);
|
||||
|
||||
$display = $view->display['default']->handler;
|
||||
|
||||
$display->override_option('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
'alter' => array(
|
||||
'alter_text' => TRUE,
|
||||
'text' => '<em>[name]</em>',
|
||||
),
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
$expected = '<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<views_tests>
|
||||
<views_test>
|
||||
<ID><![CDATA[1]]></ID>
|
||||
<Name><![CDATA[<em>John</em>]]></Name>
|
||||
<Age>25</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID><![CDATA[2]]></ID>
|
||||
<Name><![CDATA[<em>George</em>]]></Name>
|
||||
<Age>27</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID><![CDATA[3]]></ID>
|
||||
<Name><![CDATA[<em>Ringo</em>]]></Name>
|
||||
<Age>28</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID><![CDATA[4]]></ID>
|
||||
<Name><![CDATA[<em>Paul</em>]]></Name>
|
||||
<Age>26</Age>
|
||||
</views_test>
|
||||
<views_test>
|
||||
<ID><![CDATA[5]]></ID>
|
||||
<Name><![CDATA[<em>Meredith</em>]]></Name>
|
||||
<Age>30</Age>
|
||||
</views_test>
|
||||
</views_tests>';
|
||||
|
||||
$message = 'XML in values test in ' . $this->vde_export_type . ' export matched expected output.';
|
||||
|
||||
$this->executeAndCompareGivenView($view, $expected, $message, $style_options);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user