Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F174644
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
21 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/composer.json-dist b/composer.json-dist
index ffb06a1..a7b7d69 100644
--- a/composer.json-dist
+++ b/composer.json-dist
@@ -1,27 +1,27 @@
{
"name": "kolab/syncroton",
"description": "The ActiveSync Service for Kolab",
"license": "AGPL-3.0+",
"repositories": [
{
"type": "vcs",
"url": "https://git.kolab.org/diffusion/PNL/php-net_ldap.git"
}
],
"require": {
"php": ">=5.4.0",
"pear/pear-core-minimal": "~1.10.1",
"pear/net_socket": "~1.2.1",
"pear/auth_sasl": "~1.1.0",
"pear/net_idna2": "~0.2.0",
"pear/mail_mime": "~1.10.0",
"pear/net_smtp": "~1.7.1",
"pear/net_ldap2": "~2.2.0",
"pear/net_sieve": "~1.4.0",
"kolab/net_ldap3": "dev-master",
"zf1/zend-log": "~1.12.11"
},
"require-dev": {
- "phpunit/phpunit": "~4.4.0"
+ "phpunit/phpunit": "^4.8 || ^5.7 || ^6 || ^7"
}
}
diff --git a/tests/body_converter.php b/tests/body_converter.php
index 2c497ad..2300f56 100644
--- a/tests/body_converter.php
+++ b/tests/body_converter.php
@@ -1,50 +1,50 @@
<?php
-class body_converter extends PHPUnit_Framework_TestCase
+class body_converter extends PHPUnit\Framework\TestCase
{
function setUp()
{
}
function data_html_to_text()
{
return array(
array('', ''),
array('<div></div>', ''),
array('<div>a</div>', 'a'),
array('<html><head><title>title</title></head></html>', ''),
);
}
/**
* @dataProvider data_html_to_text
*/
function test_html_to_text($html, $text)
{
$converter = new kolab_sync_body_converter($html, Syncroton_Model_EmailBody::TYPE_HTML);
$output = $converter->convert(Syncroton_Model_EmailBody::TYPE_PLAINTEXT);
$this->assertEquals(trim($text), trim($output));
}
/**
*
*/
function test_rtf_to_text()
{
$rtf = '0QAAAB0CAABMWkZ1Pzsq5D8ACQMwAQMB9wKnAgBjaBEKwHNldALRcHJx4DAgVGFoA3ECgwBQ6wNUDzcyD9MyBgAGwwKDpxIBA+MReDA0EhUgAoArApEI5jsJbzAVwzEyvjgJtBdCCjIXQRb0ORIAHxeEGOEYExjgFcMyNTX/CbQaYgoyGmEaHBaKCaUa9v8c6woUG3YdTRt/Hwwabxbt/xyPF7gePxg4JY0YVyRMKR+dJfh9CoEBMAOyMTYDMUksgSc1FGAnNhqAJ1Q3My3BNAqFfS7A';
$rtf = base64_decode($rtf);
$text = 'Test';
$html = '<pre>Test</pre>';
$converter = new kolab_sync_body_converter($rtf, Syncroton_Model_EmailBody::TYPE_RTF);
$output = $converter->convert(Syncroton_Model_EmailBody::TYPE_PLAINTEXT);
$this->assertEquals(trim($text), trim($output));
$output = $converter->convert(Syncroton_Model_EmailBody::TYPE_HTML);
$this->assertEquals(trim($html), trim($output));
}
}
diff --git a/tests/data.php b/tests/data.php
index 9078b27..ab84324 100644
--- a/tests/data.php
+++ b/tests/data.php
@@ -1,74 +1,74 @@
<?php
-class data extends PHPUnit_Framework_TestCase
+class data extends PHPUnit\Framework\TestCase
{
/**
* Test for kolab_sync_data::recurrence_to_kolab()
*/
function test_recurrence_to_kolab()
{
$xml = '<!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
<Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Calendar="uri:Calendar">
<ApplicationData>
<Calendar:Recurrence>
<Calendar:Type>0</Calendar:Type>
<Calendar:Interval>1</Calendar:Interval>
<Calendar:Until>20101128T225959Z</Calendar:Until>
</Calendar:Recurrence>
</ApplicationData>
</Sync>';
$xml = new SimpleXMLElement($xml);
$event = new Syncroton_Model_Event($xml->ApplicationData);
$data = new kolab_sync_data_test;
$result = $data->recurrence_to_kolab($event);
$this->assertEquals('DAILY', $result['FREQ']);
$this->assertEquals(1, $result['INTERVAL']);
$this->assertEquals('20101128T225959Z', $result['UNTIL']->format("Ymd\THis\Z"));
$xml = '<!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
<Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Calendar="uri:Calendar">
<ApplicationData>
<Calendar:Recurrence>
<Calendar:Type>1</Calendar:Type>
<Calendar:Interval>1</Calendar:Interval>
<Calendar:DayOfWeek>8</Calendar:DayOfWeek>
</Calendar:Recurrence>
</ApplicationData>
</Sync>';
$xml = new SimpleXMLElement($xml);
$event = new Syncroton_Model_Event($xml->ApplicationData);
$result = $data->recurrence_to_kolab($event, null);
$this->assertEquals('WEEKLY', $result['FREQ']);
$this->assertEquals(1, $result['INTERVAL']);
$this->assertEquals('WE', $result['BYDAY']);
}
}
/**
* kolab_sync_data wrapper, so we can test preotected methods too
*/
class kolab_sync_data_test extends kolab_sync_data
{
function __construct()
{
}
public function recurrence_to_kolab($data, $dummy1 = null, $dummy2 = null)
{
return parent::recurrence_to_kolab($data, null);
}
function toKolab(Syncroton_Model_IEntry $data, $folderId, $entry = null, $timezone = null)
{
}
function getEntry(Syncroton_Model_SyncCollection $collection, $serverId, $as_array = false)
{
}
}
diff --git a/tests/data_calendar.php b/tests/data_calendar.php
index b82d976..1543c31 100644
--- a/tests/data_calendar.php
+++ b/tests/data_calendar.php
@@ -1,126 +1,126 @@
<?php
-class data_calendar extends PHPUnit_Framework_TestCase
+class data_calendar extends PHPUnit\Framework\TestCase
{
/**
* Test for kolab_sync_data_calendar::from_kolab_alarm()
*/
function test_from_kolab_alarm()
{
$obj = new kolab_sync_data_calendar_test;
$result = $obj->from_kolab_alarm(array());
$this->assertSame(null, $result);
$event = array('valarms' => array(array(
'action' => 'DISPLAY',
'trigger' => 'PT5M',
)));
$result = $obj->from_kolab_alarm($event);
$this->assertSame(null, $result);
$event = array('valarms' => array(array(
'action' => 'DISPLAY',
'trigger' => '-PT5M',
)));
$result = $obj->from_kolab_alarm($event);
$this->assertSame(5, $result);
$event = array('valarms' => array(array(
'action' => 'DISPLAY',
'trigger' => 'PT0M',
)));
$result = $obj->from_kolab_alarm($event);
$this->assertSame(0, $result);
$event = array('valarms' => array(array(
'action' => 'DISPLAY',
'trigger' => '-PT0M',
)));
$result = $obj->from_kolab_alarm($event);
$this->assertSame(0, $result);
$event = array('valarms' => array(array(
'action' => 'DISPLAY',
'trigger' => 'PT0S',
)));
$result = $obj->from_kolab_alarm($event);
$this->assertSame(0, $result);
// alarms on specified DateTime (T2420)
$event = array(
// no start datetime defined
'valarms' => array(
array(
'action' => 'DISPLAY',
'trigger' => new DateTime('now + 1 hour'),
),
),
);
$result = $obj->from_kolab_alarm($event);
$this->assertSame(null, $result);
$event = array(
'start' => new DateTime('now + 10 minutes'),
'valarms' => array(
array(
'action' => 'DISPLAY',
'trigger' => new DateTime('now + 1 hour'),
),
),
);
$result = $obj->from_kolab_alarm($event);
$this->assertSame(null, $result);
$event = array(
'start' => new DateTime('now + 60 minutes'),
'valarms' => array(
array(
'action' => 'DISPLAY',
'trigger' => new DateTime('now + 50 minutes'),
),
),
);
$result = $obj->from_kolab_alarm($event);
$this->assertSame(10, $result);
}
/**
* Test for kolab_sync_data_calendar::to_kolab_alarm()
*/
function test_to_kolab_alarm()
{
$obj = new kolab_sync_data_calendar_test;
$result = $obj->to_kolab_alarm(null, array());
$this->assertSame(array(), $result);
$result = $obj->to_kolab_alarm(0, array());
$this->assertSame('-PT0M', $result[0]['trigger']);
$result = $obj->to_kolab_alarm(15, array());
$this->assertSame('-PT15M', $result[0]['trigger']);
$this->assertSame('DISPLAY', $result[0]['action']);
}
}
/**
* kolab_sync_data_calendar wrapper, so we can test protected methods too
*/
class kolab_sync_data_calendar_test extends kolab_sync_data_calendar
{
function __construct()
{
}
public function from_kolab_alarm($value)
{
return parent::from_kolab_alarm($value);
}
public function to_kolab_alarm($value, $event)
{
return parent::to_kolab_alarm($value, $event);
}
}
diff --git a/tests/data_tasks.php b/tests/data_tasks.php
index 611a028..17cc981 100644
--- a/tests/data_tasks.php
+++ b/tests/data_tasks.php
@@ -1,78 +1,78 @@
<?php
-class data_tasks extends PHPUnit_Framework_TestCase
+class data_tasks extends PHPUnit\Framework\TestCase
{
function data_prio()
{
return array(
array(0, null),
array(1, 2),
array(2, 2),
array(3, 2),
array(4, 2),
array(5, 1),
array(6, 0),
array(7, 0),
array(8, 0),
array(9, 0),
// invalid input
array(10, null),
);
}
function data_importance()
{
return array(
array(0, 9),
array(1, 5),
array(2, 1),
// invalid input
array(null, null),
array(5, null),
);
}
/**
* Test for kolab_sync_data_tasks::prio_to_importance()
* @dataProvider data_prio()
*/
function test_prio_to_importance($input, $output)
{
$data = new kolab_sync_data_tasks_test;
$result = $data->prio_to_importance($input);
$this->assertEquals($output, $result);
}
/**
* Test for kolab_sync_data_tasks::importance_to_prio()
* @dataProvider data_importance()
*/
function test_importance_to_prio($input, $output)
{
$data = new kolab_sync_data_tasks_test;
$result = $data->importance_to_prio($input);
$this->assertEquals($output, $result);
}
}
/**
* kolab_sync_data_tasks wrapper, so we can test preotected methods too
*/
class kolab_sync_data_tasks_test extends kolab_sync_data_tasks
{
function __construct()
{
}
public function prio_to_importance($value)
{
return parent::prio_to_importance($value);
}
public function importance_to_prio($value)
{
return parent::importance_to_prio($value);
}
}
diff --git a/tests/message.php b/tests/message.php
index a49c5d1..14f1a39 100644
--- a/tests/message.php
+++ b/tests/message.php
@@ -1,151 +1,151 @@
<?php
-class message extends PHPUnit_Framework_TestCase
+class message extends PHPUnit\Framework\TestCase
{
function setUp()
{
}
/**
* Test message parsing and headers setting
*/
function test_headers()
{
$source = file_get_contents(TESTS_DIR . '/src/mail.plain');
$message = new kolab_sync_message($source);
$headers = $message->headers();
$this->assertArrayHasKey('MIME-Version', $headers);
$this->assertCount(8, $headers);
$this->assertEquals('kolab@domain.tld', $headers['To']);
// test set_header()
$message->set_header('to', 'test@domain.tld');
$headers = $message->headers();
$this->assertCount(8, $headers);
$this->assertEquals('test@domain.tld', $headers['To']);
}
/**
* Test message parsing
*/
function test_source()
{
$source = file_get_contents(TESTS_DIR . '/src/mail.plain');
$message = new kolab_sync_message($source);
$result = $message->source();
$this->assertEquals($source, str_replace("\r\n", "\n", $result));
}
/**
* Test adding attachments to the message
*/
function test_attachment()
{
$source = file_get_contents(TESTS_DIR . '/src/mail.plain');
$mixed = file_get_contents(TESTS_DIR . '/src/mail.plain.mixed');
$mixed2 = file_get_contents(TESTS_DIR . '/src/mail.mixed');
// test adding attachment to text/plain message
$message = new kolab_sync_message($source);
$message->add_attachment('aaa', array(
'content_type' => 'text/plain',
'encoding' => '8bit',
));
$result = $message->source();
$result = str_replace("\r\n", "\n", $result);
if (preg_match('/boundary="([^"]+)"/', $result, $m)) {
$mixed = str_replace('BOUNDARY', $m[1], $mixed);
}
$this->assertEquals($mixed, $result);
// test adding attachment to multipart/mixed message
$message = new kolab_sync_message($mixed);
$message->add_attachment('aaa', array(
'content_type' => 'text/plain',
'encoding' => 'base64',
));
$result = $message->source();
$result = str_replace("\r\n", "\n", $result);
if (preg_match('/boundary="([^"]+)"/', $result, $m)) {
$mixed2 = str_replace('BOUNDARY', $m[1], $mixed2);
}
$this->assertEquals($mixed2, $result);
}
/**
* Test appending a text to the message
*/
function test_append()
{
// test appending text to text/plain message
$source = file_get_contents(TESTS_DIR . '/src/mail.plain');
$append = file_get_contents(TESTS_DIR . '/src/mail.plain.append');
$message = new kolab_sync_message($source);
$message->append('a');
$result = $message->source();
$result = str_replace("\r\n", "\n", $result);
$this->assertEquals($append, $result);
}
/**
* Test recoding the message
*/
function test_recode_message_1()
{
$source = file_get_contents(TESTS_DIR . '/src/mail.recode1');
$result = file_get_contents(TESTS_DIR . '/src/mail.recode1.out');
$message = kolab_sync_message::recode_message($source);
$this->assertEquals($result, $message);
}
/**
* Test recoding the message
*/
function test_recode_message_2()
{
$source = file_get_contents(TESTS_DIR . '/src/mail.recode2');
$result = file_get_contents(TESTS_DIR . '/src/mail.recode2.out');
$message = kolab_sync_message::recode_message($source);
$this->assertEquals($result, $message);
}
/**
* Test recoding the message
*/
function test_recode_message_3()
{
$source = file_get_contents(TESTS_DIR . '/src/mail.recode3');
$result = file_get_contents(TESTS_DIR . '/src/mail.recode3.out');
$message = kolab_sync_message::recode_message($source);
$this->assertEquals($result, $message);
}
/**
* Test recoding the message
*/
function test_recode_message_4()
{
$source = file_get_contents(TESTS_DIR . '/src/mail.recode4');
$result = file_get_contents(TESTS_DIR . '/src/mail.recode4.out');
$message = kolab_sync_message::recode_message($source);
$this->assertEquals($result, $message);
}
}
diff --git a/tests/timezone_converter.php b/tests/timezone_converter.php
index 4dbd68e..6088322 100644
--- a/tests/timezone_converter.php
+++ b/tests/timezone_converter.php
@@ -1,116 +1,116 @@
<?php
-class timezone_converter extends PHPUnit_Framework_TestCase
+class timezone_converter extends PHPUnit\Framework\TestCase
{
function setUp()
{
}
function test_list_timezones()
{
date_default_timezone_set('America/Los_Angeles');
$converter = timezone_converter_test::getInstance();
$input = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAEAAAAAAAAAxP///w==';
$output = $converter->getListOfTimezones($input);
$this->assertTrue(is_array($output));
$converter = timezone_converter_test::getInstance();
$output = $converter->getListOfTimezones('xP///0MAZQBuAHQAcgBhAGwAIABFAHUAcgBvAHAAZQAgAFMAdABhAG4AZABhAHIAZAAgAFQAaQBtAGUAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAEMAZQBuAHQAcgBhAGwAIABFAHUAcgBvAHAAZQAgAEQAYQB5AGwAaQBnAGgAdAAgAFQAaQBtAGUAAAAAAAAAAAAAAAMAAAAFAAIAAAAAAAAAxP///w==');
$this->assertTrue(is_array($output));
$this->assertTrue(isset($output['Europe/Warsaw']));
$converter = timezone_converter_test::getInstance();
$output = $converter->getListOfTimezones('4AEAAFAAYQBjAGkAZgBpAGMAIABTAHQAYQBuAGQAYQByAGQAIABUAGkAbQBlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAIAAAAAAAAAAAAAAFAAYQBjAGkAZgBpAGMAIABEAGEAeQBsAGkAZwBoAHQAIABUAGkAbQBlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAIAAAAAAAAAxP///w==');
$this->assertTrue(is_array($output));
$this->assertTrue(isset($output['America/Los_Angeles']));
}
function test_get_timezone()
{
date_default_timezone_set('America/Los_Angeles');
$converter = timezone_converter_test::getInstance();
$datetime = new DateTime('2017-01-01T12:00:00Z');
$offsets = $converter->getOffsetsForTimezone('UTC', $datetime);
$output = $converter->getTimezone($offsets, 'UTC');
$this->assertSame('UTC', $output);
$offsets = $converter->getOffsetsForTimezone('Europe/Warsaw', $datetime);
$output = $converter->getTimezone($offsets, 'Europe/Warsaw');
$this->assertSame('Europe/Warsaw', $output);
$offsets = $converter->getOffsetsForTimezone('America/Los_Angeles', $datetime);
$output = $converter->getTimezone($offsets, 'America/Los_Angeles');
$this->assertSame('America/Los_Angeles', $output);
}
function test_get_offsets_for_timezone()
{
date_default_timezone_set('America/Los_Angeles');
$converter = timezone_converter_test::getInstance();
$datetime = new DateTime('2017-01-01T12:00:00Z');
$output = $converter->getOffsetsForTimezone('UTC', $datetime);
$this->assertSame($output['bias'], 0);
$this->assertSame($output['standardBias'], 0);
$this->assertSame($output['daylightBias'], 0);
$this->assertSame($output['standardMonth'], 0);
$this->assertSame($output['daylightMonth'], 0);
$output = $converter->getOffsetsForTimezone('Europe/Warsaw', $datetime);
$this->assertSame($output['standardBias'], 0);
$this->assertSame($output['standardMonth'], 10);
$this->assertSame($output['standardDay'], 5);
$this->assertSame($output['standardHour'], 3);
$this->assertSame($output['daylightBias'], -60);
$this->assertSame($output['daylightMonth'], 3);
$this->assertSame($output['daylightDay'], 5);
$this->assertSame($output['daylightHour'], 2);
$output = $converter->getOffsetsForTimezone('America/Los_Angeles', $datetime);
$this->assertSame($output['bias'], 480);
$this->assertSame($output['standardBias'], 0);
$this->assertSame($output['standardMonth'], 11);
$this->assertSame($output['standardDay'], 1);
$this->assertSame($output['standardHour'], 2);
$this->assertSame($output['daylightBias'], -60);
$this->assertSame($output['daylightMonth'], 3);
$this->assertSame($output['daylightDay'], 2);
$this->assertSame($output['daylightHour'], 2);
$output = $converter->getOffsetsForTimezone('Atlantic/Azores', $datetime);
$this->assertSame($output['bias'], 60);
$this->assertSame($output['standardBias'], 0);
$this->assertSame($output['standardMonth'], 10);
$this->assertSame($output['standardDay'], 5);
$this->assertSame($output['standardHour'], 1);
$this->assertSame($output['daylightBias'], -60);
$this->assertSame($output['daylightMonth'], 3);
$this->assertSame($output['daylightDay'], 5);
$this->assertSame($output['daylightHour'], 0);
}
}
class timezone_converter_test extends kolab_sync_timezone_converter
{
// disable cache
function getCache()
{
return null;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Jan 18, 7:42 PM (1 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
120001
Default Alt Text
(21 KB)
Attached To
Mode
R4 syncroton
Attached
Detach File
Event Timeline
Log In to Comment