simpletest_calendar_systems.test in Calendar Systems 7
File
simpletest_calendar_systems.test
View source
<?php
class SimpletestUnitTestExampleTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Simpletest CalendarSystems unit tests',
'description' => 'Test that CalendarSystems works properly.',
'group' => 'CalendarSystem',
);
}
public function setUp() {
parent::setUp('calendar_systems');
}
function testCalendarSystemsConversion() {
$message = "Jalali Date To Gregorian Conversion does not work properly";
$result = true;
$calendar = calendar_systems_get_calendar_instance();
for ($y = 1300; $y <= 1400; $y++) {
for ($m = 1; $m <= 12; $m++) {
for ($d = 1; $d <= $calendar
->daysInMonth($m - 1, 'jalali'); $d++) {
$fadate = $y . '/' . str_pad($m, 2, "0", STR_PAD_LEFT) . '/' . str_pad($d, 2, "0", STR_PAD_LEFT);
$_infoArray_fadate = split('/', $fadate);
$_infoArray_fadate = array(
'year' => $_infoArray_fadate[0],
'month' => $_infoArray_fadate[1],
'day' => $_infoArray_fadate[2],
);
$timestamp_birthdaf = $calendar
->infoArrayToTimestamp($_infoArray_fadate);
$birthdaf_val = date('Y-m-d', $timestamp_birthdaf);
$birthdaf_val_timestamp = $calendar
->strToTimestamp($birthdaf_val);
$check_date = format_date($birthdaf_val_timestamp, 'custom', 'Y/m/d');
if ($fadate != $check_date) {
$result = false;
$message .= " \n {$fadate} : {$check_date}";
}
}
}
}
$this
->assertTrue($result, $message);
}
public function runningOnTestbot() {
$testbot_code_directory = "../checkout";
return file_exists($testbot_code_directory);
}
}