diff --git a/.github/workflows/integration-test-cron.yml b/.github/workflows/integration-test-cron.yml
index 9c84a6e..8e144d8 100644
--- a/.github/workflows/integration-test-cron.yml
+++ b/.github/workflows/integration-test-cron.yml
@@ -65,6 +65,10 @@ jobs:
databases: pgsql
php-versions: 8.3
encryption: 'on'
+ - server-versions: stable35
+ databases: pgsql
+ php-versions: 8.3
+ encryption: 'on'
- server-versions: stable32
databases: pgsql
php-versions: 8.1
diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml
new file mode 100644
index 0000000..231f65c
--- /dev/null
+++ b/.github/workflows/phpunit-mysql.yml
@@ -0,0 +1,205 @@
+# This workflow is provided via the organization template repository
+#
+# https://github.com/nextcloud/.github
+# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
+#
+# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: MIT
+
+name: PHPUnit MySQL
+
+on: pull_request
+
+permissions:
+ contents: read
+
+concurrency:
+ group: phpunit-mysql-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ matrix:
+ runs-on: ubuntu-latest-low
+ outputs:
+ matrix: ${{ steps.versions.outputs.sparse-matrix }}
+ steps:
+ - name: Checkout app
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Get version matrix
+ id: versions
+ uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2
+ with:
+ matrix: '{"mysql-versions": ["8.4"]}'
+
+ changes:
+ runs-on: ubuntu-latest-low
+ permissions:
+ contents: read
+ pull-requests: read
+
+ outputs:
+ src: ${{ steps.changes.outputs.src}}
+
+ steps:
+ - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
+ id: changes
+ continue-on-error: true
+ with:
+ filters: |
+ src:
+ - '.github/workflows/**'
+ - 'appinfo/**'
+ - 'lib/**'
+ - 'templates/**'
+ - 'tests/**'
+ - 'vendor/**'
+ - 'vendor-bin/**'
+ - '.php-cs-fixer.dist.php'
+ - 'composer.json'
+ - 'composer.lock'
+
+ phpunit-mysql:
+ runs-on: ubuntu-latest
+
+ needs: [changes, matrix]
+ if: needs.changes.outputs.src != 'false'
+
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
+
+ name: MySQL ${{ matrix.mysql-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
+
+ services:
+ mysql:
+ image: ghcr.io/nextcloud/continuous-integration-mysql-${{ matrix.mysql-versions }}:latest # zizmor: ignore[unpinned-images]
+ ports:
+ - 4444:3306/tcp
+ env:
+ MYSQL_ROOT_PASSWORD: rootpassword
+ options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10
+
+ steps:
+ - name: Set app env
+ if: ${{ env.APP_NAME == '' }}
+ run: |
+ # Split and keep last
+ echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
+
+ - name: Checkout server
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ submodules: true
+ repository: nextcloud/server
+ ref: ${{ matrix.server-versions }}
+
+ - name: Checkout app
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ path: apps/${{ env.APP_NAME }}
+
+ - name: Set up php ${{ matrix.php-versions }}
+ uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
+ with:
+ php-version: ${{ matrix.php-versions }}
+ # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
+ extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, mysql, pdo_mysql
+ coverage: none
+ ini-file: development
+ # Temporary workaround for missing pcntl_* in PHP 8.3
+ ini-values: disable_functions=
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Enable ONLY_FULL_GROUP_BY MySQL option
+ run: |
+ echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
+ echo 'SELECT @@sql_mode;' | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
+
+ - name: Check composer file existence
+ id: check_composer
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ files: apps/${{ env.APP_NAME }}/composer.json
+
+ - name: Remove nextcloud/ocp
+ # Only run if phpunit config file exists
+ if: steps.check_composer.outputs.files_exists == 'true'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer remove nextcloud/ocp --dev --no-scripts
+
+ - name: Install composer dependencies
+ uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
+ with:
+ working-directory: apps/${{ env.APP_NAME }}
+
+ - name: Set up Nextcloud
+ env:
+ DB_PORT: 4444
+ run: |
+ mkdir data
+ ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
+ ./occ app:enable --force ${{ env.APP_NAME }}
+
+ - name: Check PHPUnit script is defined
+ id: check_phpunit
+ continue-on-error: true
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer run --list | grep '^ test:unit ' | wc -l | grep 1
+
+ - name: PHPUnit
+ # Only run if phpunit config file exists
+ if: steps.check_phpunit.outcome == 'success'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer run test:unit
+
+ - name: Check PHPUnit integration script is defined
+ id: check_integration
+ continue-on-error: true
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer run --list | grep '^ test:integration ' | wc -l | grep 1
+
+ - name: Run Nextcloud
+ # Only run if phpunit integration config file exists
+ if: steps.check_integration.outcome == 'success'
+ run: php -S localhost:8080 &
+
+ - name: PHPUnit integration
+ # Only run if phpunit integration config file exists
+ if: steps.check_integration.outcome == 'success'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer run test:integration
+
+ - name: Print logs
+ if: always()
+ run: |
+ cat data/nextcloud.log
+
+ - name: Skipped
+ # Fail the action when neither unit nor integration tests ran
+ if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
+ run: |
+ echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts'
+ exit 1
+
+ summary:
+ permissions:
+ contents: none
+ runs-on: ubuntu-latest-low
+ needs: [changes, phpunit-mysql]
+
+ if: always()
+
+ name: phpunit-mysql-summary
+
+ steps:
+ - name: Summary status
+ run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mysql.result != 'success' }}; then exit 1; fi
diff --git a/.github/workflows/phpunit-oci.yml b/.github/workflows/phpunit-oci.yml
new file mode 100644
index 0000000..4a42221
--- /dev/null
+++ b/.github/workflows/phpunit-oci.yml
@@ -0,0 +1,212 @@
+# This workflow is provided via the organization template repository
+#
+# https://github.com/nextcloud/.github
+# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
+#
+# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: MIT
+
+name: PHPUnit OCI
+
+on: pull_request
+
+permissions:
+ contents: read
+
+concurrency:
+ group: phpunit-oci-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ matrix:
+ runs-on: ubuntu-latest-low
+ outputs:
+ php-version: ${{ steps.versions.outputs.php-available-list }}
+ server-max: ${{ steps.versions.outputs.branches-max-list }}
+ steps:
+ - name: Checkout app
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Get version matrix
+ id: versions
+ uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2
+
+ changes:
+ runs-on: ubuntu-latest-low
+ permissions:
+ contents: read
+ pull-requests: read
+
+ outputs:
+ src: ${{ steps.changes.outputs.src }}
+
+ steps:
+ - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
+ id: changes
+ continue-on-error: true
+ with:
+ filters: |
+ src:
+ - '.github/workflows/**'
+ - 'appinfo/**'
+ - 'lib/**'
+ - 'templates/**'
+ - 'tests/**'
+ - 'vendor/**'
+ - 'vendor-bin/**'
+ - '.php-cs-fixer.dist.php'
+ - 'composer.json'
+ - 'composer.lock'
+
+ phpunit-oci:
+ runs-on: ubuntu-latest
+
+ needs: [changes, matrix]
+ if: needs.changes.outputs.src != 'false'
+
+ strategy:
+ fail-fast: false
+ matrix:
+ php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
+ server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
+ oci-versions: ['18', '21', '23']
+
+ name: OCI ${{ matrix.oci-versions }} PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
+
+ services:
+ oracle:
+ image: ghcr.io/gvenzl/oracle-${{ matrix.oci-versions < 23 && 'xe' || 'free' }}:${{ matrix.oci-versions }}
+
+ # Provide passwords and other environment variables to container
+ env:
+ ORACLE_PASSWORD: oracle
+
+ # Forward Oracle port
+ ports:
+ - 1521:1521
+
+ # Provide healthcheck script options for startup
+ options: >-
+ --health-cmd healthcheck.sh
+ --health-interval 20s
+ --health-timeout 10s
+ --health-retries 10
+
+ steps:
+ - name: Set app env
+ if: ${{ env.APP_NAME == '' }}
+ run: |
+ # Split and keep last
+ echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
+
+ - name: Checkout server
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ submodules: true
+ repository: nextcloud/server
+ ref: ${{ matrix.server-versions }}
+
+ - name: Checkout app
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ path: apps/${{ env.APP_NAME }}
+
+ - name: Set up php ${{ matrix.php-versions }}
+ uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
+ with:
+ php-version: ${{ matrix.php-versions }}
+ # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
+ extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, oci8
+ coverage: none
+ ini-file: development
+ # Temporary workaround for missing pcntl_* in PHP 8.3
+ ini-values: disable_functions=
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Check composer file existence
+ id: check_composer
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ files: apps/${{ env.APP_NAME }}/composer.json
+
+ - name: Remove nextcloud/ocp
+ # Only run if phpunit config file exists
+ if: steps.check_composer.outputs.files_exists == 'true'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer remove nextcloud/ocp --dev --no-scripts
+
+ - name: Install composer dependencies
+ uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
+ with:
+ working-directory: apps/${{ env.APP_NAME }}
+
+ - name: Set up Nextcloud
+ env:
+ DB_PORT: 1521
+ run: |
+ mkdir data
+ ./occ maintenance:install --verbose --database=oci --database-name=${{ matrix.oci-versions < 23 && 'XE' || 'FREE' }} --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=system --database-pass=oracle --admin-user admin --admin-pass admin
+ ./occ app:enable --force ${{ env.APP_NAME }}
+
+ - name: Check PHPUnit script is defined
+ id: check_phpunit
+ continue-on-error: true
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer run --list | grep '^ test:unit ' | wc -l | grep 1
+
+ - name: PHPUnit
+ # Only run if phpunit config file exists
+ if: steps.check_phpunit.outcome == 'success'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer run test:unit
+
+ - name: Check PHPUnit integration script is defined
+ id: check_integration
+ continue-on-error: true
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer run --list | grep '^ test:integration ' | wc -l | grep 1
+
+ - name: Run Nextcloud
+ # Only run if phpunit integration config file exists
+ if: steps.check_integration.outcome == 'success'
+ run: php -S localhost:8080 &
+
+ - name: PHPUnit integration
+ # Only run if phpunit integration config file exists
+ if: steps.check_integration.outcome == 'success'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer run test:integration
+
+ - name: Print logs
+ if: always()
+ run: |
+ cat data/nextcloud.log
+
+ - name: Skipped
+ # Fail the action when neither unit nor integration tests ran
+ if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
+ run: |
+ echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts'
+ exit 1
+
+ summary:
+ permissions:
+ contents: none
+ runs-on: ubuntu-latest-low
+ needs: [changes, phpunit-oci]
+
+ if: always()
+
+ name: phpunit-oci-summary
+
+ steps:
+ - name: Summary status
+ run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-oci.result != 'success' }}; then exit 1; fi
diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml
new file mode 100644
index 0000000..42d10d9
--- /dev/null
+++ b/.github/workflows/phpunit-pgsql.yml
@@ -0,0 +1,203 @@
+# This workflow is provided via the organization template repository
+#
+# https://github.com/nextcloud/.github
+# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
+#
+# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: MIT
+
+name: PHPUnit PostgreSQL
+
+on: pull_request
+
+permissions:
+ contents: read
+
+concurrency:
+ group: phpunit-pgsql-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ matrix:
+ runs-on: ubuntu-latest-low
+ outputs:
+ php-version: ${{ steps.versions.outputs.php-available-list }}
+ server-max: ${{ steps.versions.outputs.branches-max-list }}
+ steps:
+ - name: Checkout app
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Get version matrix
+ id: versions
+ uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2
+
+ changes:
+ runs-on: ubuntu-latest-low
+ permissions:
+ contents: read
+ pull-requests: read
+
+ outputs:
+ src: ${{ steps.changes.outputs.src }}
+
+ steps:
+ - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
+ id: changes
+ continue-on-error: true
+ with:
+ filters: |
+ src:
+ - '.github/workflows/**'
+ - 'appinfo/**'
+ - 'lib/**'
+ - 'templates/**'
+ - 'tests/**'
+ - 'vendor/**'
+ - 'vendor-bin/**'
+ - '.php-cs-fixer.dist.php'
+ - 'composer.json'
+ - 'composer.lock'
+
+ phpunit-pgsql:
+ runs-on: ubuntu-latest
+
+ needs: [changes, matrix]
+ if: needs.changes.outputs.src != 'false'
+
+ strategy:
+ fail-fast: false
+ matrix:
+ php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
+ server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
+
+ name: PostgreSQL PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
+
+ services:
+ postgres:
+ image: ghcr.io/nextcloud/continuous-integration-postgres-16:latest # zizmor: ignore[unpinned-images]
+ ports:
+ - 4444:5432/tcp
+ env:
+ POSTGRES_USER: root
+ POSTGRES_PASSWORD: rootpassword
+ POSTGRES_DB: nextcloud
+ options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
+
+ steps:
+ - name: Set app env
+ if: ${{ env.APP_NAME == '' }}
+ run: |
+ # Split and keep last
+ echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
+
+ - name: Checkout server
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ submodules: true
+ repository: nextcloud/server
+ ref: ${{ matrix.server-versions }}
+
+ - name: Checkout app
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ path: apps/${{ env.APP_NAME }}
+
+ - name: Set up php ${{ matrix.php-versions }}
+ uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
+ with:
+ php-version: ${{ matrix.php-versions }}
+ # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
+ extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, pgsql, pdo_pgsql
+ coverage: none
+ ini-file: development
+ # Temporary workaround for missing pcntl_* in PHP 8.3
+ ini-values: disable_functions=
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Check composer file existence
+ id: check_composer
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ files: apps/${{ env.APP_NAME }}/composer.json
+
+ - name: Remove nextcloud/ocp
+ # Only run if phpunit config file exists
+ if: steps.check_composer.outputs.files_exists == 'true'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer remove nextcloud/ocp --dev --no-scripts
+
+ - name: Install composer dependencies
+ uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
+ with:
+ working-directory: apps/${{ env.APP_NAME }}
+
+ - name: Set up Nextcloud
+ env:
+ DB_PORT: 4444
+ run: |
+ mkdir data
+ ./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
+ ./occ app:enable --force ${{ env.APP_NAME }}
+
+ - name: Check PHPUnit script is defined
+ id: check_phpunit
+ continue-on-error: true
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer run --list | grep '^ test:unit ' | wc -l | grep 1
+
+ - name: PHPUnit
+ # Only run if phpunit config file exists
+ if: steps.check_phpunit.outcome == 'success'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer run test:unit
+
+ - name: Check PHPUnit integration script is defined
+ id: check_integration
+ continue-on-error: true
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer run --list | grep '^ test:integration ' | wc -l | grep 1
+
+ - name: Run Nextcloud
+ # Only run if phpunit integration config file exists
+ if: steps.check_integration.outcome == 'success'
+ run: php -S localhost:8080 &
+
+ - name: PHPUnit integration
+ # Only run if phpunit integration config file exists
+ if: steps.check_integration.outcome == 'success'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer run test:integration
+
+ - name: Print logs
+ if: always()
+ run: |
+ cat data/nextcloud.log
+
+ - name: Skipped
+ # Fail the action when neither unit nor integration tests ran
+ if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
+ run: |
+ echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts'
+ exit 1
+
+ summary:
+ permissions:
+ contents: none
+ runs-on: ubuntu-latest-low
+ needs: [changes, phpunit-pgsql]
+
+ if: always()
+
+ name: phpunit-pgsql-summary
+
+ steps:
+ - name: Summary status
+ run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-pgsql.result != 'success' }}; then exit 1; fi
diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml
new file mode 100644
index 0000000..e6516c9
--- /dev/null
+++ b/.github/workflows/phpunit-sqlite.yml
@@ -0,0 +1,192 @@
+# This workflow is provided via the organization template repository
+#
+# https://github.com/nextcloud/.github
+# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
+#
+# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
+# SPDX-License-Identifier: MIT
+
+name: PHPUnit SQLite
+
+on: pull_request
+
+permissions:
+ contents: read
+
+concurrency:
+ group: phpunit-sqlite-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: true
+
+jobs:
+ matrix:
+ runs-on: ubuntu-latest-low
+ outputs:
+ php-version: ${{ steps.versions.outputs.php-available-list }}
+ server-max: ${{ steps.versions.outputs.branches-max-list }}
+ steps:
+ - name: Checkout app
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Get version matrix
+ id: versions
+ uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2
+
+ changes:
+ runs-on: ubuntu-latest-low
+ permissions:
+ contents: read
+ pull-requests: read
+
+ outputs:
+ src: ${{ steps.changes.outputs.src}}
+
+ steps:
+ - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
+ id: changes
+ continue-on-error: true
+ with:
+ filters: |
+ src:
+ - '.github/workflows/**'
+ - 'appinfo/**'
+ - 'lib/**'
+ - 'templates/**'
+ - 'tests/**'
+ - 'vendor/**'
+ - 'vendor-bin/**'
+ - '.php-cs-fixer.dist.php'
+ - 'composer.json'
+ - 'composer.lock'
+
+ phpunit-sqlite:
+ runs-on: ubuntu-latest
+
+ needs: [changes, matrix]
+ if: needs.changes.outputs.src != 'false'
+
+ strategy:
+ fail-fast: false
+ matrix:
+ php-versions: ${{ fromJson(needs.matrix.outputs.php-version) }}
+ server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }}
+
+ name: SQLite PHP ${{ matrix.php-versions }} Nextcloud ${{ matrix.server-versions }}
+
+ steps:
+ - name: Set app env
+ if: ${{ env.APP_NAME == '' }}
+ run: |
+ # Split and keep last
+ echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
+
+ - name: Checkout server
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ submodules: true
+ repository: nextcloud/server
+ ref: ${{ matrix.server-versions }}
+
+ - name: Checkout app
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ path: apps/${{ env.APP_NAME }}
+
+ - name: Set up php ${{ matrix.php-versions }}
+ uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2
+ with:
+ php-version: ${{ matrix.php-versions }}
+ # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
+ extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
+ coverage: none
+ ini-file: development
+ # Temporary workaround for missing pcntl_* in PHP 8.3
+ ini-values: disable_functions=
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Check composer file existence
+ id: check_composer
+ uses: andstor/file-existence-action@558493d6c74bf472d87c84eab196434afc2fa029 # v3.1.0
+ with:
+ files: apps/${{ env.APP_NAME }}/composer.json
+
+ - name: Remove nextcloud/ocp
+ # Only run if phpunit config file exists
+ if: steps.check_composer.outputs.files_exists == 'true'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer remove nextcloud/ocp --dev --no-scripts
+
+ - name: Install composer dependencies
+ uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0
+ with:
+ working-directory: apps/${{ env.APP_NAME }}
+
+ - name: Set up Nextcloud
+ env:
+ DB_PORT: 4444
+ run: |
+ mkdir data
+ ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
+ ./occ app:enable --force ${{ env.APP_NAME }}
+
+ - name: Check PHPUnit script is defined
+ id: check_phpunit
+ continue-on-error: true
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer run --list | grep '^ test:unit ' | wc -l | grep 1
+
+ - name: PHPUnit
+ # Only run if phpunit config file exists
+ if: steps.check_phpunit.outcome == 'success'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer run test:unit
+
+ - name: Check PHPUnit integration script is defined
+ id: check_integration
+ continue-on-error: true
+ working-directory: apps/${{ env.APP_NAME }}
+ run: |
+ composer run --list | grep '^ test:integration ' | wc -l | grep 1
+
+ - name: Run Nextcloud
+ # Only run if phpunit integration config file exists
+ if: steps.check_integration.outcome == 'success'
+ run: php -S localhost:8080 &
+
+ - name: PHPUnit integration
+ # Only run if phpunit integration config file exists
+ if: steps.check_integration.outcome == 'success'
+ working-directory: apps/${{ env.APP_NAME }}
+ run: composer run test:integration
+
+ - name: Print logs
+ if: always()
+ run: |
+ cat data/nextcloud.log
+
+ - name: Skipped
+ # Fail the action when neither unit nor integration tests ran
+ if: steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
+ run: |
+ echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts'
+ exit 1
+
+ summary:
+ permissions:
+ contents: none
+ runs-on: ubuntu-latest-low
+ needs: [changes, phpunit-sqlite]
+
+ if: always()
+
+ name: phpunit-sqlite-summary
+
+ steps:
+ - name: Summary status
+ run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-sqlite.result != 'success' }}; then exit 1; fi
diff --git a/appinfo/info.xml b/appinfo/info.xml
index b586a48..5175df1 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -40,7 +40,7 @@ Refer to the [Context Chat Backend's readme](https://github.com/nextcloud/contex
https://raw.githubusercontent.com/nextcloud/context_chat/main/screenshots/context_chat_4.png
https://raw.githubusercontent.com/nextcloud/context_chat/main/screenshots/context_chat_5.png
-
+
OCA\ContextChat\BackgroundJobs\FileSystemListenerJob
diff --git a/composer.json b/composer.json
index 4ac11b8..0dc127f 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,8 @@
"psalm:update-baseline:force": "psalm --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml",
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
- "test": "phpunit --configuration tests/phpunit.xml"
+ "test": "@test:unit",
+ "test:unit": "phpunit --configuration tests/phpunit.xml --no-coverage"
},
"config": {
"optimize-autoloader": true,
diff --git a/psalm.xml b/psalm.xml
index 06f8af7..5d7017e 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -4,6 +4,7 @@
resolveFromConfigFile="true"
findUnusedCode="false"
findUnusedBaselineEntry="false"
+ findUnusedIssueHandlerSuppression="false"
phpVersion="8.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
@@ -31,6 +32,12 @@
+
diff --git a/tests/integration/ContentManagerTest.php b/tests/integration/ContentManagerTest.php
index 2dac29c..55aff2a 100644
--- a/tests/integration/ContentManagerTest.php
+++ b/tests/integration/ContentManagerTest.php
@@ -26,11 +26,16 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use OCP\Server;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyDispatcher;
-use Test\TestCase;
+/**
+ * The test uses the real IJobList, so it needs a working database connection.
+ */
+#[Group('DB')]
class ContentManagerTest extends TestCase {
/** @var MockObject | IAppConfig */
private IAppConfig $appConfig;
diff --git a/tests/integration/ProviderConfigServiceTest.php b/tests/integration/ProviderConfigServiceTest.php
index b76646a..1e3e0cc 100644
--- a/tests/integration/ProviderConfigServiceTest.php
+++ b/tests/integration/ProviderConfigServiceTest.php
@@ -9,21 +9,20 @@
namespace OCA\ContextChat\Tests;
-use OCA\ContextChat\AppInfo\Application;
use OCA\ContextChat\Service\ProviderConfigService;
-use OCP\IConfig;
+use OCP\AppFramework\Services\IAppConfig;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class ProviderConfigServiceTest extends TestCase {
- /** @var MockObject | IConfig */
- private IConfig $config;
+ /** @var MockObject | IAppConfig */
+ private IAppConfig $appConfig;
private ProviderConfigService $providerConfig;
public function setUp(): void {
- $this->config = $this->createMock(IConfig::class);
- $this->providerConfig = new ProviderConfigService($this->config);
+ $this->appConfig = $this->createMock(IAppConfig::class);
+ $this->providerConfig = new ProviderConfigService($this->appConfig);
}
public function testGetConfigKey(): void {
@@ -60,10 +59,10 @@ public static function dataBank(): array {
* @return void
*/
public function testGetProviders(string $returnVal, array $providers): void {
- $this->config
+ $this->appConfig
->expects($this->once())
- ->method('getAppValue')
- ->with(Application::APP_ID, 'providers')
+ ->method('getAppValueString')
+ ->with('providers', '', true)
->willReturn($returnVal);
$this->assertEquals($providers, $this->providerConfig->getProviders());
@@ -94,16 +93,16 @@ public function testUpdateProvider(string $returnVal, array $providers): void {
default => json_encode($extendedProviders),
};
- $this->config
+ $this->appConfig
->expects($this->once())
- ->method('getAppValue')
- ->with(Application::APP_ID, 'providers')
+ ->method('getAppValueString')
+ ->with('providers', '', true)
->willReturn($returnVal);
- $this->config
+ $this->appConfig
->expects($returnVal === 'invalid' ? $this->exactly(2) : $this->once())
- ->method('setAppValue')
- ->with(Application::APP_ID, 'providers', $this->logicalOr($this->equalTo(''), $this->equalTo($setProvidersValue)));
+ ->method('setAppValueString')
+ ->with('providers', $this->logicalOr($this->equalTo(''), $this->equalTo($setProvidersValue)), true);
$this->providerConfig->updateProvider($appId, $providerId, $providerClass, $isInitiated);
}
@@ -119,23 +118,23 @@ public function testRemoveProvider(string $returnVal, array $providers): void {
$providerId = 'provider1';
$identifier = ProviderConfigService::getConfigKey($appId, $providerId);
- $this->config
+ $this->appConfig
->expects($this->once())
- ->method('getAppValue')
- ->with(Application::APP_ID, 'providers')
+ ->method('getAppValueString')
+ ->with('providers', '', true)
->willReturn($returnVal);
if (isset($providers[$identifier])) {
unset($providers[$identifier]);
}
- $this->config
+ $this->appConfig
->expects($returnVal === 'invalid' ? $this->exactly(2) : $this->once())
- ->method('setAppValue')
- ->with(Application::APP_ID, 'providers', $this->logicalOr(
+ ->method('setAppValueString')
+ ->with('providers', $this->logicalOr(
$this->equalTo(''),
$this->equalTo(json_encode($providers))
- ));
+ ), true);
$this->providerConfig->removeProvider($appId, $providerId);
}
@@ -150,10 +149,10 @@ public function testHasProvider(string $returnVal, array $providers): void {
$appId = 'app1';
$providerId = 'provider1';
- $this->config
+ $this->appConfig
->expects($this->once())
- ->method('getAppValue')
- ->with(Application::APP_ID, 'providers')
+ ->method('getAppValueString')
+ ->with('providers', '', true)
->willReturn($returnVal);
$expected = match ($returnVal) {