diff --git a/.github/workflows/php-test.yml b/.github/workflows/php-test.yml index 66239e7b2..992cec40b 100644 --- a/.github/workflows/php-test.yml +++ b/.github/workflows/php-test.yml @@ -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 " 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 + diff --git a/composer.json b/composer.json index c1b83846b..d362797f4 100644 --- a/composer.json +++ b/composer.json @@ -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" ], diff --git a/lib/Http/JsonResponse.php b/lib/Http/JsonResponse.php index d8f2d4e82..db7b5ffa6 100644 --- a/lib/Http/JsonResponse.php +++ b/lib/Http/JsonResponse.php @@ -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 = [], diff --git a/phpunit.integration.xml b/phpunit.integration.xml new file mode 100644 index 000000000..2be4a7bcb --- /dev/null +++ b/phpunit.integration.xml @@ -0,0 +1,37 @@ + + + + + + ../lib + + + + + + + ./tests/php/integration + + diff --git a/tests/php/integration/Db/AppointmentConfigMapperTest.php b/tests/php/integration/Db/AppointmentConfigMapperTest.php index 532e5c33f..a040d0071 100644 --- a/tests/php/integration/Db/AppointmentConfigMapperTest.php +++ b/tests/php/integration/Db/AppointmentConfigMapperTest.php @@ -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()); } } diff --git a/tests/php/integration/Db/BookingMapperTest.php b/tests/php/integration/Db/BookingMapperTest.php index d1e1f1398..9f5297ef6 100644 --- a/tests/php/integration/Db/BookingMapperTest.php +++ b/tests/php/integration/Db/BookingMapperTest.php @@ -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()); }