/usr/share/php/tests/turba/Turba/ToDo/KolabTest.php is in php-horde-turba 4.1.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | <?php
require_once __DIR__ . '/KolabTestBase.php';
/**
* @author Jason M. Felice <jason.m.felice@gmail.com>
* @package Turba
* @subpackage UnitTests
*/
class Turba_ToDo_KolabTest extends Turba_KolabTestBase {
/**
* Test setup.
*
* @return NULL
*/
public function setUp()
{
$this->markTestIncomplete('Convert to use Horde_Test.');
$this->prepareTurba();
$this->_kolab = new Kolab();
}
function testBug5476()
{
/* Open our addressbook */
$this->_kolab->open('INBOX/Contacts', 1);
$object = array(
'uid' => 1,
'given-name' => 'test',
'last-name' => 'test',
'full-name' => 'test test',
);
// Save the contact
$this->_kolab->_storage->save($object);
$object = array(
'uid' => 2,
'given-name' => 'test2',
'last-name' => 'test2',
'full-name' => 'test2 test2',
);
// Save the contact
$this->_kolab->_storage->save($object);
// Check that the driver can be created
$turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
//$this->assertNoError($turba);
$result = $turba->search(array(), array('last-name'));
$this->assertNoError($result);
$this->assertEquals(2, count($result));
$turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('INBOX%2Ftest2');
$result = $turba->search(array(), array('last-name'));
$this->assertEquals(0, count($result));
}
function testPhoto()
{
/* Open our addressbook */
$this->_kolab->open('INBOX/Contacts', 1);
$object = array(
'uid' => 1,
'given-name' => 'photo',
'last-name' => 'photo',
'full-name' => 'photo photo',
'photo' => 'abcd',
'phototype' => 'image/jpeg',
);
// Save the contact
$turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
//$this->assertNoError($turba);
$this->assertNoError($turba->_add($object));
$list = Kolab_List::singleton();
$share = &$list->getByShare('INBOX/Contacts', 'contact');
$data = &$share->getData();
$object = $data->getObject('1');
$this->assertTrue(isset($object['_attachments'][$object['picture']]));
$attachment = $data->getAttachment($object['_attachments'][$object['picture']]['key']);
$this->assertEquals("abcd\n", $attachment);
}
function testAttachments()
{
/* Open our addressbook */
$this->_kolab->open('INBOX/Contacts', 1);
$object = array(
'uid' => 'a',
'given-name' => 'atc',
'last-name' => 'atc',
'full-name' => 'atc atc',
);
// Save the contact
$turba = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create('wrobel@example.org');
//$this->assertNoError($turba);
$this->assertNoError($turba->_add($object));
$contact = $turba->getObject('a');
$this->assertNoError($contact);
$list = Kolab_List::singleton();
$share = &$list->getByShare('INBOX/Contacts', 'contact');
$data = &$share->getData();
$atc1 = Horde_Util::getTempFile();
$fh = fopen($atc1, 'w');
fwrite($fh, 'test');
fclose($fh);
$info = array('tmp_name' => $atc1,
'name' => 'test.txt');
$this->assertNoError($contact->addFile($info));
$objects = $data->getObjects();
$this->assertEquals(1, count($objects));
$object = $data->getObject('a');
$this->assertTrue(isset($object['_attachments']));
$this->assertEquals(1, count($object['_attachments']));
$this->assertEquals(1, count($object['link-attachment']));
$this->assertContains('test.txt', $object['link-attachment']);
$attachment = $data->getAttachment($object['_attachments']['test.txt']['key']);
$this->assertEquals("test\n", $attachment);
$atc1 = Horde_Util::getTempFile();
$fh = fopen($atc1, 'w');
fwrite($fh, 'hhhh');
fclose($fh);
$info = array('tmp_name' => $atc1,
'name' => 'test.txt');
$this->assertNoError($contact->addFile($info));
$objects = $data->getObjects();
$this->assertEquals(1, count($objects));
$object = $data->getObject('a');
$this->assertTrue(isset($object['_attachments']));
$this->assertEquals(2, count($object['_attachments']));
$this->assertEquals(2, count($object['link-attachment']));
$this->assertContains('test[1].txt', $object['link-attachment']);
$attachment = $data->getAttachment($object['_attachments']['test[1].txt']['key']);
$this->assertEquals("hhhh\n", $attachment);
$atc1 = Horde_Util::getTempFile();
$fh = fopen($atc1, 'w');
fwrite($fh, 'dummy');
fclose($fh);
$info = array('tmp_name' => $atc1,
'name' => 'dummy.txt');
$this->assertNoError($contact->addFile($info));
$objects = $data->getObjects();
$this->assertEquals(1, count($objects));
$object = $data->getObject('a');
$this->assertTrue(isset($object['_attachments']));
$this->assertEquals(3, count($object['_attachments']));
$this->assertEquals(3, count($object['link-attachment']));
$this->assertContains('dummy.txt', $object['link-attachment']);
$attachment = $data->getAttachment($object['_attachments']['dummy.txt']['key']);
$this->assertEquals("dummy\n", $attachment);
$this->assertError($contact->deleteFile('doesnotexist.txt'), "Unable to delete VFS file.");
$this->assertNoError($contact->deleteFile('test[1].txt'));
$objects = $data->getObjects();
$this->assertEquals(1, count($objects));
$object = $data->getObject('a');
$this->assertTrue(!isset($object['_attachments']['test[1].txt']));
$this->assertEquals(2, count($object['_attachments']));
$this->assertEquals(2, count($object['link-attachment']));
$this->assertNotContains('test[1].txt', $object['link-attachment']);
$files = $contact->listFiles();
$this->assertNoError($files);
$this->assertContains('test.txt', array_keys($files));
$this->assertContains('dummy.txt', array_keys($files));
$this->assertNoError($contact->deleteFiles());
$objects = $data->getObjects();
$this->assertEquals(1, count($objects));
$object = $data->getObject('a');
$this->assertTrue(!isset($object['_attachments']['test.txt']));
$this->assertTrue(!isset($object['_attachments']));
$this->assertTrue(!isset($object['link-attachment']));
}
}
|