View source
<?php
require_once drupal_get_path('module', 'merci') . '/tests/merci_testcase.php';
class MerciAdminTestCase extends MerciTestCase {
public static function getInfo() {
return array(
'name' => 'MERCI admin level testing',
'description' => 'Verify MERCI admin level functionality.',
'group' => 'Merci',
);
}
function setUp() {
parent::setUp();
}
function testMerciBucketContent() {
$merci_settings = array(
'merci_max_hours_per_reservation' => 5,
'merci_allow_overnight' => TRUE,
'merci_allow_weekends' => TRUE,
'merci_spare_items' => 3,
'merci_min_cancel_hours' => 3,
'merci_autocheckout' => TRUE,
'merci_autocheckin' => TRUE,
'merci_selfcheckout' => TRUE,
'merci_auto_assign_bucket_item' => TRUE,
'merci_active_status' => MERCI_STATUS_ACTIVE,
);
$bucket = $this
->merciCreateItem('bucket', NULL, $merci_settings);
$content_settings = merci_content_types($bucket->type);
$this
->verbose('settings ' . var_export($content_settings, TRUE));
$this
->verbose('settings ' . var_export($bucket, TRUE));
$this
->_compareArrayForChanges($merci_settings, $content_settings, "!key matches");
}
function _compareArrayForChanges($fields, $data, $message, $prefix = '') {
foreach ($fields as $key => $value) {
$newprefix = $prefix == '' ? $key : $prefix . '][' . $key;
if (is_array($value)) {
$compare_to = isset($data[$key]) ? $data[$key] : array();
$this
->_compareArrayForChanges($value, $compare_to, $message, $newprefix);
}
else {
$this
->assertEqual($value, $data[$key], t($message, array(
'!key' => $newprefix,
)));
}
}
}
}