Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F256586
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
14 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/composer.json-dist b/composer.json-dist
index e771f11..047a545 100644
--- a/composer.json-dist
+++ b/composer.json-dist
@@ -1,28 +1,28 @@
{
"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",
"zf1s/zend-json": "~1.12.20",
"zf1s/zend-log": "~1.12.20"
},
"require-dev": {
- "phpunit/phpunit": "^4.8 || ^5.7 || ^6 || ^7"
+ "phpunit/phpunit": "^4.8 || ^5.7 || ^6 || ^7 || ^9"
}
}
diff --git a/tests/body_converter.php b/tests/body_converter.php
index 2300f56..927042f 100644
--- a/tests/body_converter.php
+++ b/tests/body_converter.php
@@ -1,50 +1,45 @@
<?php
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/message.php b/tests/message.php
index 14f1a39..2c06aca 100644
--- a/tests/message.php
+++ b/tests/message.php
@@ -1,151 +1,146 @@
<?php
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 6184f4f..354cac1 100644
--- a/tests/timezone_converter.php
+++ b/tests/timezone_converter.php
@@ -1,161 +1,156 @@
<?php
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();
$output = $converter->getListOfTimezones('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAEAAAAAAAAAxP///w==');
$this->assertTrue(is_array($output));
$this->assertSame(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']));
$converter = timezone_converter_test::getInstance();
$output = $converter->getListOfTimezones('Lv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAwADABcAOwA7AOcDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAgAEAAAAAAAAAAAAxP///w==');
$this->assertTrue(is_array($output));
$this->assertTrue(isset($output['Asia/Tehran']));
}
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['standardWeek'], 5);
$this->assertSame($output['standardHour'], 3);
$this->assertSame($output['daylightBias'], -60);
$this->assertSame($output['daylightMonth'], 3);
$this->assertSame($output['daylightWeek'], 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['standardWeek'], 1);
$this->assertSame($output['standardHour'], 2);
$this->assertSame($output['daylightBias'], -60);
$this->assertSame($output['daylightMonth'], 3);
$this->assertSame($output['daylightWeek'], 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['standardWeek'], 5);
$this->assertSame($output['standardHour'], 1);
$this->assertSame($output['daylightBias'], -60);
$this->assertSame($output['daylightMonth'], 3);
$this->assertSame($output['daylightWeek'], 5);
$this->assertSame($output['daylightHour'], 0);
$output = $converter->getOffsetsForTimezone('Asia/Tehran', $datetime);
$this->assertSame($output['bias'], -210);
$this->assertSame($output['standardBias'], 0);
$this->assertSame($output['standardMonth'], 9);
$this->assertSame($output['standardWeek'], 3);
$this->assertSame($output['standardDayOfWeek'], 3);
$this->assertSame($output['standardHour'], 24);
$this->assertSame($output['daylightBias'], -60);
$this->assertSame($output['daylightMonth'], 3);
$this->assertSame($output['daylightWeek'], 4);
$this->assertSame($output['daylightDayOfWeek'], 2);
$this->assertSame($output['daylightHour'], 0);
}
function data_timezone_conversion()
{
return array(
array('Asia/Tehran', 'Lv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAwADABcAOwA7AOcDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAgAEAAAAAAAAAAAAxP///w=='),
array('Pacific/Pago_Pago', 'lAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=='),
array('Europe/Warsaw', 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAIAAAAAAAAAxP///w=='),
);
}
/**
* @dataProvider data_timezone_conversion
*/
function test_timezone_conversion($tz, $expected)
{
$datetime = new DateTime('2021-07-01T12:00:00Z');
$converter = timezone_converter_test::getInstance();
$output = $converter->encodeTimezone($tz, $datetime);
$this->assertSame($expected, $output);
$output = $converter->getListOfTimezones($output);
$this->assertTrue(is_array($output));
$this->assertTrue(isset($output[$tz]));
}
}
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
Sun, Jun 8, 3:31 AM (3 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
196670
Default Alt Text
(14 KB)
Attached To
Mode
R4 syncroton
Attached
Detach File
Event Timeline
Log In to Comment