Пример #1
0
<?php

require_once dirname(__FILE__) . '/entryPoint.php';
function cleanReservations(PhpgwContext $c)
{
    $reservation_tables = array('bb_booking', 'bb_allocation', 'bb_event');
    foreach ($reservation_tables as $table) {
        $sql = "TRUNCATE table {$table} CASCADE";
        echo $sql . "\n";
        $c->getDb()->query($sql, __LINE__, __FILE__);
    }
}
PhpgwEntry::phpgw_call('cleanReservations');
    }
    $c->getDb()->transaction_abort();
    sleep(4);
    print_info("Sleep test 2");
    $c->getDb()->transaction_begin();
    //Begin transaction
    $numberGeneratorInstance = get_external_generator();
    sleep(4);
    for ($i = 0; $i < 10; $i++) {
        print_info($numberGeneratorInstance->increment()->get_current());
    }
    $c->getDb()->transaction_commit();
    sleep(4);
}
function pass_test($message)
{
    echo "PASSED: " . $message . "\n";
}
function print_info($message)
{
    echo "INFO: " . $message . "\n";
}
// Create a handler function
function my_assert_handler($file, $line, $code)
{
    echo "Assertion Failed:\n" . "File '{$file}'\n" . "Line '{$line}'\n" . "Code '{$code}'\n";
}
// Set up the callback
assert_options(ASSERT_CALLBACK, 'my_assert_handler');
PhpgwEntry::phpgw_call('testNumberGenerator');
Пример #3
0
    return $resources;
}
function set_future_date($data)
{
    $start_date = strtotime(sprintf('+%s days +%s hours', rand(1, 40), rand(12, 24)));
    $end_date = strtotime(sprintf('+%s days +%s hours', rand(1, 4), rand(1, 3)), $start_date);
    $data['from_'] = date('Y-m-d H:i', $start_date) . ':00';
    $data['to_'] = date('Y-m-d H:i', $end_date) . ':00';
    echo 'Future date: ' . $data['from_'] . ' - ' . $data['to_'] . "\n";
    return $data;
}
function set_past_date($data)
{
    $end_date = strtotime(sprintf('-%s days -%s hours', rand(2, 40), rand(1, 12)));
    $start_date = strtotime(sprintf('-%s days -%s hours', rand(1, 4), rand(1, 3)), $end_date);
    $data['from_'] = date('Y-m-d H:i', $start_date) . ':00';
    $data['to_'] = date('Y-m-d H:i', $end_date) . ':00';
    echo 'Past date: ' . $data['from_'] . ' - ' . $data['to_'] . "\n";
    return $data;
}
function set_current_date($data)
{
    $start_date = strtotime(sprintf('-%s days -%s hours', rand(0, 2), rand(1, 6)));
    $end_date = strtotime(sprintf('+%s days +%s hours', rand(0, 2), rand(1, 6)));
    $data['from_'] = date('Y-m-d H:i', $start_date) . ':00';
    $data['to_'] = date('Y-m-d H:i', $end_date) . ':00';
    echo 'Current date: ' . $data['from_'] . ' - ' . $data['to_'] . "\n";
    return $data;
}
PhpgwEntry::phpgw_call('randomReservations');
<?php

require_once dirname(__FILE__) . '/entryPoint.php';
function getBookingAppVersion(PhpgwContext $c)
{
    $sql = "SELECT app_version FROM phpgw_applications WHERE app_name = 'booking' LIMIT 1";
    echo $sql . "\n";
    $c->getDb()->query($sql, __LINE__, __FILE__);
    $c->getDb()->next_record();
    echo 'Current Version: ' . $c->getDb()->f('app_version') . "\n";
}
PhpgwEntry::phpgw_call('getBookingAppVersion');
<?php

require_once dirname(__FILE__) . '/entryPoint.php';
function updateReservationState(PhpgwContext $c)
{
    CreateObject('booking.async_task_update_reservation_state')->run();
}
PhpgwEntry::phpgw_call('updateReservationState');
Пример #6
0
<?php

require_once dirname(__FILE__) . '/entryPoint.php';
function sendReminder(PhpgwContext $c)
{
    CreateObject('booking.async_task_send_reminder')->run();
}
PhpgwEntry::phpgw_call('sendReminder');
<?php

require_once dirname(__FILE__) . '/entryPoint.php';
function cleanCompletedReservations(PhpgwContext $c)
{
    $reservation_tables = array('bb_completed_reservation');
    foreach ($reservation_tables as $table) {
        $sql = "TRUNCATE table {$table} CASCADE";
        echo $sql . "\n";
        $c->getDb()->query($sql, __LINE__, __FILE__);
    }
}
PhpgwEntry::phpgw_call('cleanCompletedReservations');