From 4082f72a54bfafca419a6a9e76bd52ce1fd79ad9 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 29 Sep 2019 09:35:30 +0200 Subject: [PATCH] Add a script to run all tests, fix errors when running tests in non-kolab env --- .../libkolab/tests/kolab_date_recurrence.php | 12 ++++++ .../libkolab/tests/kolab_storage_config.php | 24 +++++++++++ .../libkolab/tests/kolab_storage_folder.php | 40 +++++++++++++++++++ run-tests.sh | 16 ++++++++ 4 files changed, 92 insertions(+) create mode 100755 run-tests.sh diff --git a/plugins/libkolab/tests/kolab_date_recurrence.php b/plugins/libkolab/tests/kolab_date_recurrence.php index 4cd138e2..ad0f3216 100644 --- a/plugins/libkolab/tests/kolab_date_recurrence.php +++ b/plugins/libkolab/tests/kolab_date_recurrence.php @@ -36,6 +36,10 @@ class kolab_date_recurrence_test extends PHPUnit_Framework_TestCase */ function test_first_occurrence($recurrence_data, $start, $expected) { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $start = new DateTime($start); if (!empty($recurrence_data['UNTIL'])) { $recurrence_data['UNTIL'] = new DateTime($recurrence_data['UNTIL']); @@ -216,6 +220,10 @@ class kolab_date_recurrence_test extends PHPUnit_Framework_TestCase */ function test_first_occurrence_allday($recurrence_data, $start, $expected) { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $start = new DateTime($start); if (!empty($recurrence_data['UNTIL'])) { $recurrence_data['UNTIL'] = new DateTime($recurrence_data['UNTIL']); @@ -236,6 +244,10 @@ class kolab_date_recurrence_test extends PHPUnit_Framework_TestCase */ function test_next_instance() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + date_default_timezone_set('America/New_York'); $start = new DateTime('2017-08-31 11:00:00', new DateTimeZone('Europe/Berlin')); diff --git a/plugins/libkolab/tests/kolab_storage_config.php b/plugins/libkolab/tests/kolab_storage_config.php index c4ab3a6c..9be7841f 100644 --- a/plugins/libkolab/tests/kolab_storage_config.php +++ b/plugins/libkolab/tests/kolab_storage_config.php @@ -34,6 +34,10 @@ class kolab_storage_config_test extends PHPUnit_Framework_TestCase $rcube = rcmail::get_instance(); $rcube->plugins->load_plugin('libkolab', true, true); + if (!kolab_format::supports(3)) { + return; + } + if ($rcube->config->get('tests_username')) { $authenticated = $rcube->login( $rcube->config->get('tests_username'), @@ -70,6 +74,10 @@ class kolab_storage_config_test extends PHPUnit_Framework_TestCase function test_001_build_member_url() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $rcube = rcube::get_instance(); $email = $rcube->get_user_email(); $personal = str_replace('$user', urlencode($email), $this->url_personal); @@ -89,6 +97,10 @@ class kolab_storage_config_test extends PHPUnit_Framework_TestCase function test_002_parse_member_url() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $rcube = rcube::get_instance(); $email = $rcube->get_user_email(); $personal = str_replace('$user', urlencode($email), $this->url_personal); @@ -113,6 +125,10 @@ class kolab_storage_config_test extends PHPUnit_Framework_TestCase function test_003_build_parse_member_url() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + // personal namespace $params = $this->params_personal; $params_ = kolab_storage_config::parse_member_url(kolab_storage_config::build_member_url($params)); @@ -138,6 +154,10 @@ class kolab_storage_config_test extends PHPUnit_Framework_TestCase */ function test_save() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $config = kolab_storage_config::get_instance(); $tags = array( array( @@ -171,6 +191,10 @@ class kolab_storage_config_test extends PHPUnit_Framework_TestCase */ function test_T133() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $config = kolab_storage_config::get_instance(); // get tags diff --git a/plugins/libkolab/tests/kolab_storage_folder.php b/plugins/libkolab/tests/kolab_storage_folder.php index ed42b9aa..3affac30 100644 --- a/plugins/libkolab/tests/kolab_storage_folder.php +++ b/plugins/libkolab/tests/kolab_storage_folder.php @@ -29,6 +29,10 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase $rcmail = rcmail::get_instance(); $rcmail->plugins->load_plugin('libkolab', true, true); + if (!kolab_format::supports(3)) { + return; + } + if ($rcmail->config->get('tests_username')) { $authenticated = $rcmail->login( $rcmail->config->get('tests_username'), @@ -65,6 +69,10 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase function test_001_folder_type_check() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $folder = new kolab_storage_folder('Calendar', 'event', 'event.default'); $this->assertTrue($folder->valid); $this->assertEquals($folder->get_error(), 0); @@ -80,6 +88,10 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase function test_002_get_owner() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $rcmail = rcmail::get_instance(); $folder = new kolab_storage_folder('Calendar', 'event', 'event'); $this->assertEquals($folder->get_owner(), $rcmail->config->get('tests_username')); @@ -97,6 +109,10 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase function test_003_get_resource_uri() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $rcmail = rcmail::get_instance(); $foldername = 'Calendar'; $uri = parse_url($rcmail->config->get('default_host')); @@ -112,6 +128,10 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase function test_004_get_uid() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $rcmail = rcmail::get_instance(); $folder = new kolab_storage_folder('Doesnt-Exist', 'event', 'event'); @@ -123,6 +143,10 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase function test_005_subscribe() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $folder = new kolab_storage_folder('Contacts', 'contact'); $this->assertTrue($folder->subscribe(true)); $this->assertTrue($folder->is_subscribed()); @@ -135,6 +159,10 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase function test_006_activate() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $folder = new kolab_storage_folder('Calendar', 'event'); $this->assertTrue($folder->activate(true)); $this->assertTrue($folder->is_active()); @@ -145,6 +173,10 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase function test_010_write_contacts() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $contacts = array( 'name' => 'FN', 'surname' => 'Last', @@ -164,12 +196,20 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase */ function test_011_list_contacts() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $folder = new kolab_storage_folder('Contacts', 'contact'); $this->assertEquals($folder->count(), 1); } function test_T491_get_uid() { + if (!kolab_format::supports(3)) { + $this->markTestSkipped('No Kolab support'); + } + $rcmail = rcmail::get_instance(); $imap = $rcmail->get_storage(); $db = $rcmail->get_dbh(); diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 00000000..587f558a --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +PHPUNIT=`which phpunit` + +if [ -f "vendor/phpunit/phpunit/phpunit" ]; then + PHPUNIT="../vendor/phpunit/phpunit/phpunit" +fi + +cd tests + +$PHPUNIT ../plugins/libkolab/tests/kolab_date_recurrence.php +$PHPUNIT ../plugins/libkolab/tests/kolab_storage_config.php +$PHPUNIT ../plugins/libkolab/tests/kolab_storage_folder.php + +$PHPUNIT ../plugins/libcalendaring/tests/libcalendaring.php +$PHPUNIT ../plugins/libcalendaring/tests/libvcalendar.php