Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/finance-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ jobs:
run: PYTHONDONTWRITEBYTECODE=1 python3 tests/ci/test-report-timing.py
- name: Verify synthetic restricted-funding acceptance fixtures (not runtime)
run: python3 tests/acceptance/restricted-funding/verify-fixtures.py
- name: Verify exact currency arithmetic (no ledger mutation)
run: |
php tests/unit/currency-conversion.php
php tests/unit/currency-rate-quote.php
- run: php tests/openapi/generate.php --check
- run: npm run test:openapi
- run: npm run build
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/php-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Adapted from the LibreCodeCoop organization PHP workflow templates.
# https://github.com/LibreCodeCoop/.github/tree/main/workflow-templates
#
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2026 LibreCode Coop and contributors
# SPDX-License-Identifier: MIT

name: PHP unit tests

on: pull_request

permissions:
contents: read

concurrency:
group: php-unit-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
matrix:
runs-on: ubuntu-latest
outputs:
php-versions: ${{ steps.versions.outputs.php-versions }}
steps:
- name: Checkout app
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Get version matrix
id: versions
uses: nextcloud-libraries/nextcloud-version-matrix@71959de73c244b11ecbf4503b87c41d65b0f64ae # v1.3.4

unit:
runs-on: ubuntu-latest
needs: matrix
strategy:
fail-fast: false
matrix:
php-versions: ${{ fromJSON(needs.matrix.outputs.php-versions) }}

name: PHP unit tests (${{ matrix.php-versions }})

steps:
- name: Checkout app
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # v2.40.0
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring
coverage: none
ini-file: development

- name: Install Composer dependencies
uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # v4.0.0

- name: Unit tests
run: composer run test:unit

summary:
permissions:
contents: none
runs-on: ubuntu-latest
needs: [matrix, unit]
if: always()
name: php-unit-summary
steps:
- name: Summary status
run: |
test "${{ needs.matrix.result }}" = 'success'
test "${{ needs.unit.result }}" = 'success'
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ SPDX-License-Identifier: AGPL-3.0-or-later
- Use \`OCP\DB\QueryBuilder\` for DB changes. Test SQLite, MariaDB and PostgreSQL; maintain immutable migrations.
- No secrets in source, logs, screenshots, issues or PR descriptions. Remote banking, NFS-e, AI, payments and signatures are optional modules with explicit authorization.
- Build and validate PHP and Vue separately. Never commit generated `js/` or `css/`; build assets for development, browser CI and the App Store archive. Keep OpenAPI versioned. A route or a green CI that skipped tests is not proof of financial correctness.
- PHP unit tests use PHPUnit and mirror existing production classes: `lib/Domain/Currency/ExactConversion.php` maps to `tests/php/Unit/Domain/Currency/ExactConversionTest.php` and the matching namespace. Keep one test class per existing source class, do not invent generic or unmatched unit test classes, and place tests requiring an installed Nextcloud or database in the integration suite. Run `composer test:unit` (or filter by class/method during development).
- PRs: incremental signed commits with DCO, no automatic squash; follow LibreCode repository governance.
- Issue and epic creation requires exact human approval after drafting and review. Do not publish private commercial context.
15 changes: 15 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,28 @@
"require": {
"php": "^8.3"
},
"require-dev": {
"phpunit/phpunit": "^12.5"
},
"config": {
"platform": {
"php": "8.3.0"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"OCA\\LibreFinance\\": "lib/"
}
},
"autoload-dev": {
"psr-4": {
"OCA\\LibreFinance\\Tests\\Unit\\": "tests/php/Unit/"
}
},
"scripts": {
"lint": "find appinfo lib -type f -name '*.php' -print0 | xargs -0 -n 1 php -l",
"test:unit": "phpunit --configuration phpunit.xml --testsuite unit --no-coverage",
"openapi": "@php tests/openapi/generate.php",
"openapi:check": "@php tests/openapi/generate.php --check"
}
Expand Down
Loading