/**
 * Destructor cleanup for a test record
 *
 * @param Doctrine_Record $proto
 * @param string  $uuid
 */
function trec_destruct($proto, $uuid = null)
{
    if (!$uuid) {
        if (isset($proto->my_uuid)) {
            $uuid = $proto->my_uuid;
        } else {
            return;
            // nothing to delete
        }
    }
    // setup table vars
    $vars = trec_get_vars($proto);
    $tbl = $proto->getTable();
    $name = get_class($proto);
    $conn = $tbl->getConnection();
    // look for stale record
    $stale = $tbl->findOneBy($vars['UUID_COL'], $uuid);
    if ($stale && $stale->exists()) {
        if (getenv('AIR_DEBUG')) {
            diag("delete()ing stale {$name}: {$uuid}");
        }
        try {
            // ACTUALLY ... don't turn off key checks, to get cascading deletes
            //            $conn->execute('SET FOREIGN_KEY_CHECKS = 0');
            $stale->delete();
            //            $conn->execute('SET FOREIGN_KEY_CHECKS = 1');
        } catch (Exception $err) {
            diag($err);
        }
    }
    // put UUID back on the stack
    $vars['UUIDS'][] = $uuid;
}
Example #2
0
function test_is($result, $expected, $explanation)
{
    if ($result === $expected) {
        pass($explanation);
    } else {
        fail($explanation);
        diag("Got '{$result}'");
        diag("Expected '{$expected}'");
    }
}
Example #3
0
function _log_handler_test_wrapper($level, $msg, $more = array())
{
    $type = $more['type'] ? $more['type'] : $level;
    $out = '';
    if ($type) {
        $out .= "[{$type}] ";
    }
    $out .= $msg;
    if ($more['time'] > -1) {
        $out .= " ({$more['time']} ms)";
    }
    diag($out);
}
Example #4
0
function _proclaim($cond, $desc = '', $todo = false, $have = null, $want = null, $negate = false)
{
    global $__Test;
    $__Test['run'] += 1;
    # We're in a TODO block via todo_start()/todo_end(). TODO via specific
    # functions is currently unimplemented and will probably stay that way
    if (count($__Test['todo'])) {
        $todo = true;
    }
    # Everything after the first # is special, so escape user-supplied messages
    $desc = str_replace('#', '\\#', $desc);
    $desc = str_replace("\n", '\\n', $desc);
    $ok = $cond ? "ok" : "not ok";
    $directive = '';
    if ($todo) {
        $todo_idx = count($__Test['todo']) - 1;
        $directive .= ' # TODO ' . $__Test['todo'][$todo_idx];
    }
    printf("%s %d %s%s\n", $ok, $__Test['run'], $desc, $directive);
    # report a failure
    if (!$cond) {
        # Every public function in this file calls _proclaim so our culprit is
        # the second item in the stack
        $caller = debug_backtrace();
        $call = $caller['1'];
        if ($have != null || $want != null) {
            diag(sprintf(" Failed%stest '%s'\n in %s at line %d\n have: %s\n  want: %s", $todo ? ' TODO ' : ' ', $desc, $call['file'], $call['line'], $have, $want));
        } else {
            diag(sprintf(" Failed%stest '%s'\n in %s at line %d", $todo ? ' TODO ' : ' ', $desc, $call['file'], $call['line']));
        }
    }
    return $cond;
}
#!/usr/bin/php -q
<?php 
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('getTagggedMembersInPhoto');
plan(5);
connectDatabase();
$tagged1 = array(1, 2, 3);
$prev1 = array(1);
$result1 = getAddRemoveTaggedMembers($tagged1, $prev1);
$tagged2 = array(1, 2, 3);
$prev2 = array(4);
$result2 = getAddRemoveTaggedMembers($tagged2, $prev2);
$tagged3 = array(2);
$prev3 = array(1, 2, 3);
$result3 = getAddRemoveTaggedMembers($tagged3, $prev3);
$tagged4 = null;
$prev4 = array(1, 2, 3);
$result4 = getAddRemoveTaggedMembers($tagged4, $prev4);
$tagged5 = array(1, 2, 3);
$prev5 = null;
$result5 = getAddRemoveTaggedMembers($tagged5, $prev5);
is($result1, array('add' => array(2, 3), 'remove' => array()), 'Tagged and previous (adding)');
is($result2, array('add' => array(1, 2, 3), 'remove' => array(4)), 'Tagged and previous (adding & removing)');
is($result3, array('add' => array(), 'remove' => array(1, 3)), 'Tagged and previous (removing)');
is($result4, array('add' => array(), 'remove' => array(1, 2, 3)), 'Previous (removing)');
is($result5, array('add' => array(1, 2, 3), 'remove' => array()), 'Tagged (adding)');
Example #6
0
function _test_end()
{
    global $_no_plan;
    global $_num_failures;
    global $_test_num;
    if ($_no_plan) {
        echo "1..{$_test_num}\n";
    }
    if ($_num_failures) {
        diag("Looks like you failed {$_num_failures} tests of {$_test_num}.");
    }
}
Example #7
0
#!/usr/bin/php -q
<?php 
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('removeBBCode');
plan(3);
$matching_mixed_missing_in = '[b]bold[/b] [b]still bold[/B] [B]also bold';
$matching_mixed_missing_out = removeBBCode($matching_mixed_missing_in);
is($matching_mixed_missing_out, 'bold still bold [B]also bold', 'matching, mixed, missing');
$intermixed_in = '[b]bold [ins]inserted[/ins][/b]';
$intermixed_out = removeBBCode($intermixed_in);
is($intermixed_out, 'bold inserted', 'intermixed');
$bad_intermixed_in = '[b]bold [ins][/b]inserted[/ins]';
$bad_intermixed_out = removeBBCode($bad_intermixed_in);
is($bad_intermixed_out, 'bold inserted', 'bad intermixed');
Example #8
0
#!/usr/bin/php -q
<?php 
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('cleanOutput');
plan(2);
$js_in = '<script type="text/javascript">alert("hey")</script>';
$js_out = cleanOutput($js_in);
is($js_out, 'alert(&quot;hey&quot;)', 'javascript');
$js_html_in = '<script type="text/javascript">alert("hey")</script>';
$js_html_out = cleanOutput($js_html_in, 'html');
is($js_html_out, '&lt;script type=&quot;text/javascript&quot;&gt;alert(&quot;hey&quot;)&lt;/script&gt;', 'javascript html');
<?php

$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-Simple.php';
require_once $lib;
plan('no_plan');
diag('Test of deprecated Test::More functions provided for compatibility completeness.');
$foo = array(0 => 1, 1 => 'B', 2 => 'third');
$oof = array(0 => 'third', 1 => 'B', 2 => 1);
$bar = array('q' => 23, 'Y' => 42);
$rab = array('Y' => 42, 'q' => 23);
ok(eq_array($foo, $oof), 'eq_array() with misordered array is ok');
ok(eq_array($bar, $rab), 'eq_array() with misordered assoc is ok');
ok(eq_hash($foo, $oof), 'eq_hash() with misordered array is ok');
ok(eq_hash($bar, $rab), 'eq_hash() with misordered assoc is ok');
ok(eq_set($foo, $oof), 'eq_set() with misordered array is ok');
ok(eq_set($bar, $rab), 'eq_set() with misordered assoc is ok');
done_testing();
Example #10
0
function check($board, $col)
{
    // vertical
    if (checkFour(vert($board, $col))) {
        return true;
    }
    // horizontal
    if (checkFour(horiz($board, $col))) {
        return true;
    }
    // diagonal (right)
    if (checkFour(diag($board, $col, 1))) {
        return true;
    }
    // diagonal (left)
    if (checkFour(diag($board, $col, 0))) {
        return true;
    }
    return false;
}
Example #11
0
#!/usr/bin/php -q
<?php 
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'User.php';
require_once INC . 'Error.php';
require_once INC . 'Database.php';
require_once INC . 'utils.php';
require_once INC . 'constants.php';
diag("getTheme");
plan(2);
connectDatabase();
$theme_no_id = getTheme();
$theme_bad_id = getTheme(0);
is($theme_no_id, UI . 'themes/default/', 'no userid');
is($theme_bad_id, UI . 'themes/default/', 'bad userid');
<?php

$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-Simple.php';
require_once $lib;
plan(3);
diag('If PHP throws a fatal error, bail as nicely as possible.');
ok(1, "Pass one for good measure");
include_ok($lib, 'Including a library again should redefine a function and bail.');
ok(1, 'This test will not be reached.');
Example #13
0
is($message->getID(), $contactMessageId, "Checking opening message ID");
is($message->getBodyContentFormat(), "txt", "Checking body content format");
diag("Setting multiple messages properties to first set");
$message->set(PidTagBody, $pidTagBody1, PidLidWorkAddressStreet, $pidLidWorkAddressStreet1, PidLidEmail1EmailAddress, $pidLidEmail1EmailAddress1);
diag("Setting one property PidTagDisplayName to first set");
$message->set(PidTagDisplayName, $pidTagDisplayName1);
$message->save();
unset($message);
diag("- Saving changes");
$message = $contacts->openMessage($contactMessageId, MAPIMessage::RW);
ok($message, "Reopening message in RW mode");
is($message->get(PidTagDisplayName), $pidTagDisplayName1, "Checking PidTagDisplayName1 has changed properly");
$multipleValues = $message->get(PidTagBody, PidLidWorkAddressStreet, PidLidEmail1EmailAddress);
is($multipleValues[PidTagBody], $pidTagBody1, "Checking value as PidTagBody (retrieved in a multiple value get)");
is($multipleValues[PidLidWorkAddressStreet], $pidLidWorkAddressStreet1, "Checking value as PidLidWorkAddressStreet (retrieved in a multiple value get)");
is($multipleValues[PidLidEmail1EmailAddress], $pidLidEmail1EmailAddress1, "Checking value as PidLidEmail1EmailAddress (retrieved in a multiple value get)");
diag("Setting values again");
$message->set(PidTagBody, $pidTagBody2, PidLidWorkAddressStreet, $pidLidWorkAddressStreet2, PidLidEmail1EmailAddress, $pidLidEmail1EmailAddress2);
$message->set(PidTagDisplayName, $pidTagDisplayName2);
$message->save();
unset($message);
diag("- Saving last changes");
$message = $contacts->openMessage($contactMessageId, MAPIMessage::RO);
ok($message, "Reopening message in RO mode");
is($message->get(PidTagDisplayName), $pidTagDisplayName2, "Checking PidTagDisplayName2 has changed properly");
$multipleValues = $message->get(PidTagBody, PidLidWorkAddressStreet, PidLidEmail1EmailAddress);
is($multipleValues[PidTagBody], $pidTagBody2, "Checking value as PidTagBody (retrieved in a multiple value get)");
is($multipleValues[PidLidWorkAddressStreet], $pidLidWorkAddressStreet2, "Checking value as PidLidWorkAddressStreet (retrieved in a multiple value get)");
is($multipleValues[PidLidEmail1EmailAddress], $pidLidEmail1EmailAddress2, "Checking value as PidLidEmail2EmailAddress (retrieved in a multiple value get)");
unset($message);
endTestSuite("message.php");
<?php

$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-More.php';
require_once $lib;
plan('no_plan');
diag("Assertions:");
is_deeply(NULL, NULL);
is_deeply(TRUE, TRUE);
is_deeply(FALSE, FALSE);
is_deeply(42, 42);
is_deeply('abcdef', 'abcdef');
is_deeply(array(), array());
is_deeply(array(1), array(1));
is_deeply(array(array()), array(array()));
is_deeply(array(array(123)), array(array(123)));
is_deeply(array(1, 'abc'), array(0 => 1, 1 => 'abc'));
diag("Denials:");
isnt_deeply(NULL, TRUE, 'NULL !== TRUE');
isnt_deeply(NULL, FALSE, 'NULL !== FALSE');
isnt_deeply(NULL, 0, 'NULL !== 0');
isnt_deeply(NULL, '', "NULL !== ''");
isnt_deeply(0, FALSE, '0 !== FALSE');
isnt_deeply(1, TRUE, '1 !== TRUE');
Example #15
0
#!/usr/bin/php -q
<?php 
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('parse');
plan(3);
define('URL_PREFIX', '');
$in_str_entities = '<a href="#">link</a>';
$out_str_entities = '&lt;a href=&quot;#&quot;&gt;link&lt;/a&gt;';
$in_str_smilies = ':(:smile:';
$out_str_smilies = '<img src="' . URL_PREFIX . 'ui/smileys/sad.gif" alt=":("/><img src="' . URL_PREFIX . 'ui/smileys/smile.gif" alt=":smile:"/>';
$in_str_spaces = 'line 1
line 2

line 4



line 8';
$out_str_spaces = 'line 1<br/>line 2<br/><br/>line 4<br/><br/><br/><br/>line 8';
is($out_str_entities, parse($in_str_entities), 'htmlentities');
is($out_str_smilies, parse($in_str_smilies), 'smilies');
is($out_str_spaces, parse($in_str_spaces), 'spacing');
Example #16
0
#!/usr/bin/php -q
<?php 
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag("getEmailHeaders");
plan(4);
$header = getEmailHeaders('Bob', '*****@*****.**');
$headers = explode("\r\n", $header);
is($headers[0], 'From: Bob <*****@*****.**>', 'from');
is($headers[1], 'Reply-To: bob@mail.com', 'reply-to');
is($headers[2], 'Content-Type: text/plain; charset=UTF-8;', 'content charset');
is($headers[3], 'MIME-Version: 1.0', 'mime');
Example #17
0
ok($message, "Appointment {$taskId} opened in RW mode");
is($message->getID(), $taskId, "Check opened message Id (must be {$taskId})");
dumpTask($message);
diag("Changing PidTagBody to '{$tagBody1}'");
diag("Changing PidLidTaskComplete to '{$tagComplete}'");
diag("Changing PidLidTaskComplete to '{$dateFinished}'");
diag("Changing PidLidTaskStatus to '{$status}'");
echo "\n";
$message->set(PidTagBody, $tagBody1, PidLidTaskStatus, $status, PidLidTaskDateCompleted, $dateFinished, PidLidTaskComplete, $tagComplete);
echo "\n";
diag("Changing PidLidPercentComplete to {$percent}\n");
$message->set(PidLidPercentComplete, $percent);
$message->set($PidNameKeywords, $keywords);
$message->save();
unset($message);
diag("--After saving changes:");
$message = $ocFolder->openMessage($taskId, MAPIMessage::RW);
ok($message, "Reopen message in RW mode after saving changes");
is($message->get(PidTagBody), $tagBody1, "Checking change in PidTagBody");
is($message->get(PidLidTaskStatus), $status, "Checking change in PidLidTaskStatus");
is($message->get(PidLidTaskComplete), $tagComplete, "Checking change in PidLidTaskComplete");
echo "PidLidTaskDateCompleted: " . $message->get(PidLidTaskDateCompleted) . " NOT WORKING PROPERLY. USING WORKAROUND IN ROUNDCUBE " . "\n";
is($message->get(PidLidPercentComplete), $percent, "Checking change in PidLidPercentComplete");
var_dump($message->get($PidNameKeywords));
diag("-- Reverting changes");
$message->set(PidTagBody, $undoTagBody1, PidLidTaskStatus, $undoStatus, PidLidTaskDateCompleted, $undoDateFinished, PidLidTaskComplete, $undoTagComplete);
$message->set(PidLidPercentComplete, $undoPercent);
$message->set($PidNameKeywords, $undoKeywords);
$message->save();
unset($message);
endTestSuite("task.php");
Example #18
0
#!/usr/bin/php -q
<?php 
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('cleanFilename');
plan(2);
$spaces_in = 'New Microsoft Office Word Document.docx';
$spaces_out = cleanFilename($spaces_in);
is($spaces_out, 'New_Microsoft_Office_Word_Document.docx', 'spaces');
$special_chr_in = 'test@#$%^&*()- 2314.zip';
$special_chr_out = cleanFilename($special_chr_in);
is($special_chr_out, 'test-_2314.zip', 'special characters');
Example #19
0
is($message->getID(), $appointmentId, "Check opened message Id (msut be {$appointment_id})");
diag("Changing PidTagBody to '{$tagBody1}'");
$message->set(PidTagBody, $tagBody1);
diag("Changing  PidLidAppointmentEndWhole to {$unixtime1} (09/26/2013 @ 10:02am in EST.)");
$message->set(PidLidAppointmentEndWhole, $unixtime1);
$message->save();
unset($message);
diag("--After saving changes:");
$message = $calendar->openMessage($appointmentId, MAPIMessage::RW);
ok($message, "Reopen message in RW mode after saving changes");
is($message->get(PidTagBody), $tagBody1, "Checking that PidTagBody has correctly been changed");
is($message->get(PidLidAppointmentEndWhole), $unixtime1, "Checking that PidLidAppointmentEndWhole has correctly been changed");
diag("Changing PidTagBody again to {$tagBody2}");
$message->set(PidTagBody, $tagBody2);
diag("Changing  PidLidAppointmentEndWhole to 100 seconds more");
$message->set(PidLidAppointmentEndWhole, $unixtime2);
$message->save();
unset($message);
diag("--After last changes:");
$message = $calendar->openMessage($appointmentId, MAPIMessage::RO);
ok($message, "Reopen message in RO mode after saving the last changes");
is($message->get(PidTagBody), $tagBody2, "Checking that PidTagBody has changed again");
is($message->get(PidLidAppointmentEndWhole), $unixtime2, "Checking that PidLidAppointmentEndWhole has changed again");
# workaround against shutdown problem
unset($message);
#unset($calendar);
#unset($mailbox);
#unset($session);
#unset($mapiProfile);
#unset($mapi);
endTestSuite("appointment.php");
 /**
  * Destroy stuff in the database
  */
 function __destruct()
 {
     $conn = AIR2_DBManager::get_master_connection();
     // build the "where"
     $where = array();
     foreach ($this->where_fields as $idx => $fld) {
         $where[] = "{$fld} = ?";
     }
     $where = implode(' and ', $where);
     // count before deleting
     $q = "select count(*) from {$this->tbl_name} where {$where}";
     $num = $conn->fetchOne($q, $this->where_values, 0);
     if ($num > $this->max_delete) {
         $msg = "UNABLE TO CLEANUP - more than {$this->max_delete} rows";
         $msg .= " returned by query --> {$q}";
         throw new Exception($msg);
     }
     // execute delete
     $q = "delete from {$this->tbl_name} where {$where}";
     $del = $conn->exec($q, $this->where_values);
     if ($del != $num) {
         $msg = "PROBLEM CLEANING UP: expected to delete {$num}, got {$del}!";
         $msg .= "  Query --> {$q}";
         throw new Exception($msg);
     }
     // debug output
     if (getenv('AIR_DEBUG')) {
         diag("TestCleanup deleted {$del} stale {$this->tbl_name}");
     }
 }
Example #21
0
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include './test-helpers.php';
include './config.php';
$mapi = new MAPIProfileDB($pathDB);
ok($mapi, "MAPIProfileDB open for path {$pathDB}");
is($mapi->path(), $pathDB, "MAPI DB correct path");
$inexistent = $mapi->getProfile("idonotexist_232");
ok(is_null($inexistent), "Checking that trying to get inexistent profile return NULL");
$mapiProfile = $mapi->getProfile($profileName);
ok($mapiProfile, "Getting profile {$profileName}");
$session = $mapiProfile->logon();
ok($session, "Logon with profile {$profileName}");
$mailbox = $session->mailbox();
ok($mailbox, "Get default mailbox");
diag("Mailbox name " . $mailbox->getName());
$contacts = $mailbox->contacts();
ok($contacts, "Get contacts folder");
$messageTable = $contacts->getMessageTable();
ok($messageTable, "Get message table from contacts folder");
ok($messageTable->count() > 0, "Checking that message table contains messages");
$message = $contacts->openMessage($messageId);
ok($message, "Get message with ID {$messageId}");
is($message->getID(), $messageId, "Check opened message Id (must be {$messageId})");
#unset($mapi); # do not work..
#unset($profile);
#unset($session);
#unset($mailbox);
#unset($contacts);
#unset($messages);
endTestSuite("simple-hierarchy.php");
$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-More.php';
require_once $lib;
#plan(3);
diag('Test of various functions not otherwise broken out.');
pass("pass() is ok");
fail("fail() is not ok");
is('Ab3', 'Ab3', 'is() is ok');
isnt('Ab3', 123, 'isnt() is ok');
like('yackowackodot', '/wacko/', "like() is ok");
unlike('yackowackodot', '/boing/', "unlike() is ok");
cmp_ok(12, '>', 10, 'cmp_ok() is ok');
can_ok($__Test, 'plan');
isa_ok($__Test, 'TestMore', 'Default Testing object');
include_ok('t/goodlib.php');
require_ok('t/goodpage.php');
$foo = array(1, 'B', 'third');
$oof = array('third', 'B', 1);
$bar = array('q' => 23, 'Y' => 42);
$rab = array('Y' => 42, 'q' => 23);
is_deeply($foo, $foo, 'is_deeply() is ok');
isnt_deeply($foo, $bar, 'isnt_deeply() is ok');
/*
function skip($SkipReason, $num) {
function todo ($why, $howmany) {
function todo_skip ($why, $howmany) {
function todo_start ($why) {
function todo_end () {
*/
diag("Should fail 1 test, testing fail()");
done_testing();
   Copyright (C) 2013-2014 Javier Amor Garcia

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include './test-helpers.php';
include './config.php';
diag("Test disabled for now");
exit(0);
$mapi = new MAPIProfileDB($dbPath);
echo "=> MAPI Profile Database Path: '", $mapi->path(), "'\n";
$mapiProfile = $mapi->getProfile($profileName);
$session = $mapiProfile->logon();
$mailbox = $session->mailbox();
$inbox = $mailbox->inbox();
echo "=> Opening calensdar Folder\n";
$calendar = $mailbox->calendar();
$event = $calendar->openMessage($eventId);
$recur = $event->getRecurrence(PidLidAppointmentRecur);
var_dump($recur);
<?php

$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-Simple.php';
require_once $lib;
plan(5);
diag('Should fail 3 of 5 tests');
ok(1, "Pass one");
include_ok('missing.php', 'Including a missing file should be not ok');
include_ok('badlib.php', 'Including a file with bad syntax should be not ok');
include_ok('borklib.php', 'Including a file with non-syntactical errors should be not ok');
ok(1, 'Continue testing after failed include');
Example #25
0
function endTestSuite($msg)
{
    diag("END test suite: {$msg}");
}
Example #26
0
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
include './test-helpers.php';
include './config.php';
$mapi = new MAPIProfileDB($dbPath);
ok($mapi, "MAPIProfileDB for {$dbPath}");
$mapiProfile = $mapi->getProfile();
ok($mapiProfile, "Profile {$profile}");
$session = $mapiProfile->logon();
ok($session, "Logon for profile {$profile}");
$mailbox = $session->mailbox();
ok($mailbox, "Get default mailbox");
$inbox = $mailbox->inbox();
ok($inbox, "Get inbox");
diag("Inbox item type " . $inbox->getFolderType());
$inboxId = $inbox->getID();
$table1 = $inbox->getFolderTable();
ok($table1, "Get folder table for inbox");
$parentFolder = $table1->getParentFolder();
ok($parentFolder, "Get parent folder for table");
is($parentFolder->getID(), $inboxId, "Checking by ID that parent is the inbox");
ok($table1->count() > 0, "Check that table is not empty");
# XXX continue whern we have folders..
$folders = $table1->getFolders();
var_dump($folders);
echo "First folder ID " . $folders[0]->getID() . "\n";
echo "Get othe folder table\n";
$table2 = $inbox->getFolderTable();
var_dump($table2);
echo "Folder table summary\n";
Example #27
0
$mailbox = $session->mailbox();
ok($mailbox, "Default mailbox");
$contacts = $mailbox->contacts();
ok($contacts, "Open contacts folder");
$ids = array();
$newContact = $contacts->createMessage(PidLidEmail1EmailAddress, '*****@*****.**', PidTagCompanyName, 'to_delete_org', PidTagDisplayName, 'first');
ok($newContact, "Created new contact");
is(get_class($newContact), "MAPIContact", "Check returned new class type");
$ids[] = $newContact->getID();
unset($newContact);
$newContact = $contacts->createMessage(PidLidEmail1EmailAddress, '*****@*****.**', PidTagCompanyName, 'to_delete_org', PidTagDisplayName, 'second');
ok($newContact, "Created a second new contact");
is(get_class($newContact), "MAPIContact", "Check returned new class type for second new contact");
$ids[] = $newContact->getID();
unset($newContact);
foreach ($ids as $newId) {
    $retrieved = $contacts->openMessage($newId);
    ok($retrieved, "Check that we can retrieve a new created contact by its ID={$newId}");
    is(get_class($retrieved), "MAPIContact", "Check class type for retrieved contact");
    is($retrieved->getID(), $newId, "Check ID for retrieved contact");
    unset($retrieved);
}
diag("Delete created contacts");
call_user_func_array(array($contacts, 'deleteMessages'), $ids);
foreach ($ids as $newId) {
    $retrieved = $contacts->openMessage($newId);
    ok(is_null($retrieved), "Check that removed contact {$newId} has been removed");
}
diag("Try to delete inexistent contact. XXX does not return error because SOGO limitation");
$contacts->deleteMessages($inexistentContactId);
endTestSuite("new_message.php");