chore: add integration tests to CI

Signed-off-by: Anna Larch <anna@nextcloud.com>
This commit is contained in:
Anna Larch 2023-06-12 10:58:54 +02:00
parent be93496cde
commit 488d8f6437
6 changed files with 91 additions and 25 deletions

View File

@ -51,10 +51,55 @@ jobs:
fail_ci_if_error: true
verbose: true
integration-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '8.0', '8.1', '8.2' ]
nextcloud-versions: [ 'master']
include:
- php-versions: '7.4'
nextcloud-versions: 'stable25'
- php-versions: '8.1'
nextcloud-versions: 'stable26'
- php-versions: '8.1'
nextcloud-versions: 'stable27'
name: php${{ matrix.php-versions }} on ${{ matrix.nextcloud-versions }} integration tests
env:
CI: true
XDEBUG_MODE: coverage
steps:
- name: Set up php${{ matrix.php-versions }}
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, curl, dom, gd, gmp, iconv, intl, json, mbstring, openssl, pdo_sqlite, posix, sqlite, xml, zip
coverage: xdebug
- name: Checkout Nextcloud
run: git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${{ matrix.nextcloud-versions }} nextcloud
- name: Patch version check for nightly PHP
if: ${{ matrix.php-versions == '8.2' }}
run: echo "<?php" > nextcloud/lib/versioncheck.php
- name: Install Nextcloud
run: php -f nextcloud/occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database sqlite --database-pass=''
- name: Checkout the app
uses: actions/checkout@v3
with:
path: nextcloud/apps/calendar
- name: Install dependencies
working-directory: nextcloud/apps/calendar
run: composer install
- name: Install Calendar
run: php -f nextcloud/occ app:enable calendar
- name: Run tests
working-directory: nextcloud/apps/calendar
run: composer run test:integration
summary:
runs-on: ubuntu-latest
needs:
- unit-tests
- integration-tests
if: always()
@ -63,3 +108,6 @@ jobs:
steps:
- name: Unit test status
run: if ${{ needs.unit-tests.result != 'success' && needs.unit-tests.result != 'skipped' }}; then exit 1; fi
- name: Integration test status
run: if ${{ needs.integration-tests.result != 'success' && needs.integration-tests.result != 'skipped' }}; then exit 1; fi

View File

@ -26,6 +26,8 @@
"psalm": "psalm",
"test": "phpunit --configuration phpunit.unit.xml --fail-on-warning",
"test:dev": "phpunit --configuration phpunit.unit.xml --fail-on-warning --stop-on-error --stop-on-failure",
"test:integration": "phpunit -c phpunit.integration.xml --fail-on-warning",
"test:integration:dev": "phpunit -c phpunit.integration.xml --no-coverage --order-by=defects --stop-on-defect --fail-on-warning --stop-on-error --stop-on-failure",
"post-install-cmd": [
"@composer bin all install --ansi"
],

View File

@ -37,6 +37,8 @@ use function get_class;
/**
* @see https://github.com/omniti-labs/jsend
*
* @psalm-suppress MissingTemplateParam
*/
class JsonResponse extends Base {
public function __construct($data = [],

37
phpunit.integration.xml Normal file
View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
~
~ @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
~
~ @license GNU AGPL version 3 or any later version
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as
~ published by the Free Software Foundation, either version 3 of the
~ License, or (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/php/unit/bootstrap.php"
verbose="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">../lib</directory>
</include>
<report>
<clover outputFile="./clover.integration.xml"/>
</report>
</coverage>
<testsuite name="integration">
<directory suffix="Test.php">./tests/php/integration</directory>
</testsuite>
</phpunit>

View File

@ -78,21 +78,14 @@ class AppointmentConfigMapperTest extends TestCase {
$id = $appointment->getId();
$appointment = $this->mapper->findById($id);
$this->assertObjectHasAttribute('token', $appointment);
$this->assertEquals('okens', $appointment->getToken());
$this->assertObjectHasAttribute('name', $appointment);
$this->assertEquals('Test 2', $appointment->getName());
$this->assertObjectHasAttribute('description', $appointment);
$this->assertEquals('Test Description', $appointment->getDescription());
$this->assertObjectHasAttribute('increment', $appointment);
$this->assertEquals(15 * 60, $appointment->getIncrement());
$this->assertObjectHasAttribute('length', $appointment);
$this->assertEquals(60 * 60, $appointment->getLength());
$this->assertObjectHasAttribute('targetCalendarUri', $appointment);
$this->assertEquals('testuri', $appointment->getTargetCalendarUri());
$this->assertObjectHasAttribute('visibility', $appointment);
$this->assertEquals(AppointmentConfig::VISIBILITY_PUBLIC, $appointment->getVisibility());
$this->assertObjectHasAttribute('userId', $appointment);
$this->assertEquals('testuser', $appointment->getUserId());
}
@ -114,21 +107,14 @@ class AppointmentConfigMapperTest extends TestCase {
$token = $appointment->getToken();
$appointment = $this->mapper->findByToken($token);
$this->assertObjectHasAttribute('token', $appointment);
$this->assertEquals('okensdsadsas', $appointment->getToken());
$this->assertObjectHasAttribute('name', $appointment);
$this->assertEquals('Test 2', $appointment->getName());
$this->assertObjectHasAttribute('description', $appointment);
$this->assertEquals('Test Description', $appointment->getDescription());
$this->assertObjectHasAttribute('increment', $appointment);
$this->assertEquals(15 * 60, $appointment->getIncrement());
$this->assertObjectHasAttribute('length', $appointment);
$this->assertEquals(60 * 60, $appointment->getLength());
$this->assertObjectHasAttribute('targetCalendarUri', $appointment);
$this->assertEquals('testuri', $appointment->getTargetCalendarUri());
$this->assertObjectHasAttribute('visibility', $appointment);
$this->assertEquals(AppointmentConfig::VISIBILITY_PUBLIC, $appointment->getVisibility());
$this->assertObjectHasAttribute('userId', $appointment);
$this->assertEquals('testuser', $appointment->getUserId());
}
@ -149,7 +135,6 @@ class AppointmentConfigMapperTest extends TestCase {
$this->assertNotEmpty($appointments);
foreach ($appointments as $appointment) {
$this->assertObjectHasAttribute('userId', $appointment);
$this->assertEquals('testuser', $appointment->getUserId());
}
}

View File

@ -84,21 +84,13 @@ class BookingMapperTest extends TestCase {
$token = $booking->getToken();
$booking = $this->mapper->findByToken($token);
$this->assertObjectHasAttribute('apptConfigId', $booking);
$this->assertEquals('1', $booking->getApptConfigId());
$this->assertObjectHasAttribute('createdAt', $booking);
$this->assertEquals($this->time->getTime(), $booking->getCreatedAt());
$this->assertObjectHasAttribute('token', $booking);
$this->assertEquals('oken', $booking->getToken());
$this->assertObjectHasAttribute('displayName', $booking);
$this->assertEquals('Test', $booking->getDisplayName());
$this->assertObjectHasAttribute('start', $booking);
$this->assertEquals(123, $booking->getStart());
$this->assertObjectHasAttribute('end', $booking);
$this->assertEquals(123, $booking->getEnd());
$this->assertObjectHasAttribute('email', $booking);
$this->assertEquals('test@test.com', $booking->getEmail());
$this->assertObjectHasAttribute('timezone', $booking);
$this->assertEquals('Europe/Berlin', $booking->getTimezone());
}