Add a script to run all tests, fix errors when running tests in non-kolab env

This commit is contained in:
Aleksander Machniak 2019-09-29 09:35:30 +02:00
parent 07554a5db0
commit 4082f72a54
4 changed files with 92 additions and 0 deletions

View file

@ -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'));

View file

@ -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

View file

@ -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();

16
run-tests.sh Executable file
View file

@ -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