test: move PHPUnit configuration into the tests directory (#8376)

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
This commit is contained in:
Thomas Vincent authored and GitHub committed 2026-10-14 18:55:26 -04:00
1 parent 356f4ae813
commit 5ab64dc058
55 files changed
+289 -258

No files matched your search

+2 -2
View File
@@ -48,8 +48,8 @@ CHANGELOG merge=union
/build/psalm/ export-ignore /build/psalm/ export-ignore
/docker-compose.yml export-ignore /docker-compose.yml export-ignore
/phpstan-baseline.neon export-ignore /phpstan-baseline.neon export-ignore
/phpunit.xml export-ignore /tests/phpunit.xml export-ignore
/phpunit-*.xml export-ignore /tests/phpunit-*.xml export-ignore
/psalm-baseline.xml export-ignore /psalm-baseline.xml export-ignore
/psalm.xml export-ignore /psalm.xml export-ignore
/rector.php export-ignore /rector.php export-ignore
@@ -10,7 +10,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'lib/api_automation_tools.php' - 'lib/api_automation_tools.php'
- 'phpunit-api-automation-tools.xml' - 'tests/phpunit-api-automation-tools.xml'
- 'tests/Coverage/ApiAutomationToolsCoverageTest.php' - 'tests/Coverage/ApiAutomationToolsCoverageTest.php'
- 'tests/Unit/Security/SqlInjection/AutomationPreparedInClauseTest.php' - 'tests/Unit/Security/SqlInjection/AutomationPreparedInClauseTest.php'
- 'tests/fixtures/automation_prepared_in_clause_probe.php' - 'tests/fixtures/automation_prepared_in_clause_probe.php'
@@ -23,7 +23,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'lib/api_automation_tools.php' - 'lib/api_automation_tools.php'
- 'phpunit-api-automation-tools.xml' - 'tests/phpunit-api-automation-tools.xml'
- 'tests/Coverage/ApiAutomationToolsCoverageTest.php' - 'tests/Coverage/ApiAutomationToolsCoverageTest.php'
- 'tests/Unit/Security/SqlInjection/AutomationPreparedInClauseTest.php' - 'tests/Unit/Security/SqlInjection/AutomationPreparedInClauseTest.php'
- 'tests/fixtures/automation_prepared_in_clause_probe.php' - 'tests/fixtures/automation_prepared_in_clause_probe.php'
@@ -41,4 +41,4 @@ jobs:
uses: ./.github/workflows/script-coverage.yml uses: ./.github/workflows/script-coverage.yml
with: with:
job-name: API automation tools 100% coverage job-name: API automation tools 100% coverage
phpunit-config: phpunit-api-automation-tools.xml phpunit-config: tests/phpunit-api-automation-tools.xml
+8 -8
View File
@@ -14,9 +14,9 @@ on:
- 'lib/api_aggregate.php' - 'lib/api_aggregate.php'
- 'lib/cdef.php' - 'lib/cdef.php'
- 'lib/rrd.php' - 'lib/rrd.php'
- 'phpunit-cdef.xml' - 'tests/phpunit-cdef.xml'
- 'phpunit-cdef-integration.xml' - 'tests/phpunit-cdef-integration.xml'
- 'phpunit.xml' - 'tests/phpunit.xml'
- 'tests/Coverage/CdefCoverageTest.php' - 'tests/Coverage/CdefCoverageTest.php'
- 'tests/Helpers/CdefCoverageBootstrap.php' - 'tests/Helpers/CdefCoverageBootstrap.php'
- 'tests/integration/CdefDatabaseIntegrationTest.php' - 'tests/integration/CdefDatabaseIntegrationTest.php'
@@ -36,9 +36,9 @@ on:
- 'lib/api_aggregate.php' - 'lib/api_aggregate.php'
- 'lib/cdef.php' - 'lib/cdef.php'
- 'lib/rrd.php' - 'lib/rrd.php'
- 'phpunit-cdef.xml' - 'tests/phpunit-cdef.xml'
- 'phpunit-cdef-integration.xml' - 'tests/phpunit-cdef-integration.xml'
- 'phpunit.xml' - 'tests/phpunit.xml'
- 'tests/Coverage/CdefCoverageTest.php' - 'tests/Coverage/CdefCoverageTest.php'
- 'tests/Helpers/CdefCoverageBootstrap.php' - 'tests/Helpers/CdefCoverageBootstrap.php'
- 'tests/integration/CdefDatabaseIntegrationTest.php' - 'tests/integration/CdefDatabaseIntegrationTest.php'
@@ -100,7 +100,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
include/vendor/bin/pest \ include/vendor/bin/pest \
--configuration=phpunit-cdef.xml \ --configuration=tests/phpunit-cdef.xml \
--coverage \ --coverage \
--coverage-text \ --coverage-text \
--min=100 --min=100
@@ -113,4 +113,4 @@ jobs:
CACTI_TEST_DB_NAME: cacti_test CACTI_TEST_DB_NAME: cacti_test
CACTI_TEST_DB_USER: cacti CACTI_TEST_DB_USER: cacti
CACTI_TEST_DB_PASS: cacti CACTI_TEST_DB_PASS: cacti
run: include/vendor/bin/pest --configuration=phpunit-cdef-integration.xml run: include/vendor/bin/pest --configuration=tests/phpunit-cdef-integration.xml
+2 -2
View File
@@ -13,7 +13,7 @@ on:
- 'include/cli_check.php' - 'include/cli_check.php'
- 'include/cli_only.php' - 'include/cli_only.php'
- 'lib/Console/**' - 'lib/Console/**'
- 'phpunit-cli-coverage.xml' - 'tests/phpunit-cli-coverage.xml'
- 'tests/fixtures/Console/**' - 'tests/fixtures/Console/**'
- 'tests/.htaccess' - 'tests/.htaccess'
- 'tests/index.php' - 'tests/index.php'
@@ -31,7 +31,7 @@ on:
- 'include/cli_check.php' - 'include/cli_check.php'
- 'include/cli_only.php' - 'include/cli_only.php'
- 'lib/Console/**' - 'lib/Console/**'
- 'phpunit-cli-coverage.xml' - 'tests/phpunit-cli-coverage.xml'
- 'tests/fixtures/Console/**' - 'tests/fixtures/Console/**'
- 'tests/.htaccess' - 'tests/.htaccess'
- 'tests/index.php' - 'tests/index.php'
@@ -10,7 +10,7 @@ on:
- 'composer.lock' - 'composer.lock'
- 'lib/client_address.php' - 'lib/client_address.php'
- 'lib/functions.php' - 'lib/functions.php'
- 'phpunit-client-address.xml' - 'tests/phpunit-client-address.xml'
- 'tests/Coverage/ClientAddressCoverageTest.php' - 'tests/Coverage/ClientAddressCoverageTest.php'
- 'tests/Unit/Security/Misc/GetClientAddrTest.php' - 'tests/Unit/Security/Misc/GetClientAddrTest.php'
pull_request: pull_request:
@@ -22,7 +22,7 @@ on:
- 'composer.lock' - 'composer.lock'
- 'lib/client_address.php' - 'lib/client_address.php'
- 'lib/functions.php' - 'lib/functions.php'
- 'phpunit-client-address.xml' - 'tests/phpunit-client-address.xml'
- 'tests/Coverage/ClientAddressCoverageTest.php' - 'tests/Coverage/ClientAddressCoverageTest.php'
- 'tests/Unit/Security/Misc/GetClientAddrTest.php' - 'tests/Unit/Security/Misc/GetClientAddrTest.php'
workflow_dispatch: workflow_dispatch:
@@ -39,5 +39,5 @@ jobs:
uses: ./.github/workflows/script-coverage.yml uses: ./.github/workflows/script-coverage.yml
with: with:
job-name: Client address 100% coverage job-name: Client address 100% coverage
phpunit-config: phpunit-client-address.xml phpunit-config: tests/phpunit-client-address.xml
php-version: '8.4' php-version: '8.4'
+1 -1
View File
@@ -97,7 +97,7 @@ jobs:
- name: Run PHP cookie matrix - name: Run PHP cookie matrix
run: >- run: >-
include/vendor/bin/pest include/vendor/bin/pest --configuration=tests/phpunit.xml
tests/Unit/Security/Session/CookiePolicyContractTest.php tests/Unit/Security/Session/CookiePolicyContractTest.php
tests/Unit/Security/Session/CookieRuntimeTest.php tests/Unit/Security/Session/CookieRuntimeTest.php
tests/integration/AuthSystemRegressionIntegrationTest.php tests/integration/AuthSystemRegressionIntegrationTest.php
+1 -1
View File
@@ -61,7 +61,7 @@ jobs:
node-version: '22' node-version: '22'
- name: Verify guarded actions and links - name: Verify guarded actions and links
run: include/vendor/bin/pest tests/Unit/Security/Csrf/ItemActionPostOnlyTest.php run: include/vendor/bin/pest --configuration=tests/phpunit.xml tests/Unit/Security/Csrf/ItemActionPostOnlyTest.php
- name: Verify browser POST construction - name: Verify browser POST construction
run: node --test tests/js/csrf_post_actions.test.js run: node --test tests/js/csrf_post_actions.test.js
+3 -3
View File
@@ -10,7 +10,7 @@ on:
- 'composer.lock' - 'composer.lock'
- 'include/csrf.php' - 'include/csrf.php'
- 'lib/csrf.php' - 'lib/csrf.php'
- 'phpunit-csrf-coverage.xml' - 'tests/phpunit-csrf-coverage.xml'
- 'tests/Unit/Security/Csrf/**' - 'tests/Unit/Security/Csrf/**'
pull_request: pull_request:
branches: [develop] branches: [develop]
@@ -21,7 +21,7 @@ on:
- 'composer.lock' - 'composer.lock'
- 'include/csrf.php' - 'include/csrf.php'
- 'lib/csrf.php' - 'lib/csrf.php'
- 'phpunit-csrf-coverage.xml' - 'tests/phpunit-csrf-coverage.xml'
- 'tests/Unit/Security/Csrf/**' - 'tests/Unit/Security/Csrf/**'
workflow_dispatch: workflow_dispatch:
@@ -62,7 +62,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
include/vendor/bin/pest \ include/vendor/bin/pest \
--configuration=phpunit-csrf-coverage.xml \ --configuration=tests/phpunit-csrf-coverage.xml \
--coverage \ --coverage \
--coverage-text \ --coverage-text \
--min=100 --min=100
+3 -3
View File
@@ -10,7 +10,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'scripts/ss_entity_sensor.php' - 'scripts/ss_entity_sensor.php'
- 'phpunit-entity-sensor.xml' - 'tests/phpunit-entity-sensor.xml'
- 'tests/Unit/DataCollection/Scripts/EntitySensorTest.php' - 'tests/Unit/DataCollection/Scripts/EntitySensorTest.php'
pull_request: pull_request:
branches: [develop] branches: [develop]
@@ -21,7 +21,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'scripts/ss_entity_sensor.php' - 'scripts/ss_entity_sensor.php'
- 'phpunit-entity-sensor.xml' - 'tests/phpunit-entity-sensor.xml'
- 'tests/Unit/DataCollection/Scripts/EntitySensorTest.php' - 'tests/Unit/DataCollection/Scripts/EntitySensorTest.php'
workflow_dispatch: workflow_dispatch:
@@ -37,5 +37,5 @@ jobs:
uses: ./.github/workflows/script-coverage.yml uses: ./.github/workflows/script-coverage.yml
with: with:
job-name: scripts/ss_entity_sensor.php 100% coverage job-name: scripts/ss_entity_sensor.php 100% coverage
phpunit-config: phpunit-entity-sensor.xml phpunit-config: tests/phpunit-entity-sensor.xml
extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring, snmp extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring, snmp
+3 -3
View File
@@ -10,7 +10,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'scripts/ss_f5_cpu.php' - 'scripts/ss_f5_cpu.php'
- 'phpunit-f5-cpu.xml' - 'tests/phpunit-f5-cpu.xml'
- 'tests/Unit/DataCollection/Scripts/F5CpuTest.php' - 'tests/Unit/DataCollection/Scripts/F5CpuTest.php'
pull_request: pull_request:
branches: [develop] branches: [develop]
@@ -21,7 +21,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'scripts/ss_f5_cpu.php' - 'scripts/ss_f5_cpu.php'
- 'phpunit-f5-cpu.xml' - 'tests/phpunit-f5-cpu.xml'
- 'tests/Unit/DataCollection/Scripts/F5CpuTest.php' - 'tests/Unit/DataCollection/Scripts/F5CpuTest.php'
workflow_dispatch: workflow_dispatch:
@@ -37,5 +37,5 @@ jobs:
uses: ./.github/workflows/script-coverage.yml uses: ./.github/workflows/script-coverage.yml
with: with:
job-name: scripts/ss_f5_cpu.php 100% coverage job-name: scripts/ss_f5_cpu.php 100% coverage
phpunit-config: phpunit-f5-cpu.xml phpunit-config: tests/phpunit-f5-cpu.xml
extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring, snmp extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring, snmp
+3 -3
View File
@@ -8,7 +8,7 @@ on:
- '.github/workflows/form-coverage.yml' - '.github/workflows/form-coverage.yml'
- '.github/actions/setup-php-composer/**' - '.github/actions/setup-php-composer/**'
- 'lib/CactiForm.php' - 'lib/CactiForm.php'
- 'phpunit-form-coverage.xml' - 'tests/phpunit-form-coverage.xml'
- 'sites.php' - 'sites.php'
- 'tests/Unit/CactiFormTest.php' - 'tests/Unit/CactiFormTest.php'
- 'tests/integration/CactiFormIntegrationTest.php' - 'tests/integration/CactiFormIntegrationTest.php'
@@ -19,7 +19,7 @@ on:
- '.github/workflows/form-coverage.yml' - '.github/workflows/form-coverage.yml'
- '.github/actions/setup-php-composer/**' - '.github/actions/setup-php-composer/**'
- 'lib/CactiForm.php' - 'lib/CactiForm.php'
- 'phpunit-form-coverage.xml' - 'tests/phpunit-form-coverage.xml'
- 'sites.php' - 'sites.php'
- 'tests/Unit/CactiFormTest.php' - 'tests/Unit/CactiFormTest.php'
- 'tests/integration/CactiFormIntegrationTest.php' - 'tests/integration/CactiFormIntegrationTest.php'
@@ -37,4 +37,4 @@ jobs:
uses: ./.github/workflows/script-coverage.yml uses: ./.github/workflows/script-coverage.yml
with: with:
job-name: Form API 100% coverage job-name: Form API 100% coverage
phpunit-config: phpunit-form-coverage.xml phpunit-config: tests/phpunit-form-coverage.xml
+2 -2
View File
@@ -146,7 +146,7 @@ jobs:
install-args: --no-interaction --no-progress --prefer-dist install-args: --no-interaction --no-progress --prefer-dist
- name: Run Pest unit suite - name: Run Pest unit suite
run: include/vendor/bin/pest --testsuite=Unit --filter=HtmxTest run: include/vendor/bin/pest --configuration=tests/phpunit.xml --testsuite=Unit --filter=HtmxTest
integration: integration:
name: Pest integration (PHP ${{ matrix.php }}) name: Pest integration (PHP ${{ matrix.php }})
@@ -185,7 +185,7 @@ jobs:
# AuthSystemRegressionIntegrationTest.php declares db_* stubs that fatal # AuthSystemRegressionIntegrationTest.php declares db_* stubs that fatal
# against the real lib/database.php the sibling DB tests require. # against the real lib/database.php the sibling DB tests require.
- name: Run Pest integration suite - name: Run Pest integration suite
run: include/vendor/bin/pest tests/integration/HtmxLoaderTest.php run: include/vendor/bin/pest --configuration=tests/phpunit.xml tests/integration/HtmxLoaderTest.php
e2e: e2e:
name: Playwright e2e name: Playwright e2e
+4 -4
View File
@@ -18,7 +18,7 @@ on:
- 'lib/import.php' - 'lib/import.php'
- 'lib/installer.php' - 'lib/installer.php'
- 'lib/utility.php' - 'lib/utility.php'
- 'phpunit-installer.xml' - 'tests/phpunit-installer.xml'
- 'tests/Unit/Installer/**' - 'tests/Unit/Installer/**'
- 'tests/Unit/Security/Csrf/InstallerCsrfRecoveryTest.php' - 'tests/Unit/Security/Csrf/InstallerCsrfRecoveryTest.php'
- 'tests/e2e/installer_resilience_docker.sh' - 'tests/e2e/installer_resilience_docker.sh'
@@ -42,7 +42,7 @@ on:
- 'lib/import.php' - 'lib/import.php'
- 'lib/installer.php' - 'lib/installer.php'
- 'lib/utility.php' - 'lib/utility.php'
- 'phpunit-installer.xml' - 'tests/phpunit-installer.xml'
- 'tests/Unit/Installer/**' - 'tests/Unit/Installer/**'
- 'tests/Unit/Security/Csrf/InstallerCsrfRecoveryTest.php' - 'tests/Unit/Security/Csrf/InstallerCsrfRecoveryTest.php'
- 'tests/e2e/installer_resilience_docker.sh' - 'tests/e2e/installer_resilience_docker.sh'
@@ -86,7 +86,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
composer test -- --colors=never \ composer test -- --colors=never \
--configuration=phpunit-installer.xml \ --configuration=tests/phpunit-installer.xml \
--testsuite='Installer Unit' \ --testsuite='Installer Unit' \
--fail-on-empty-test-suite \ --fail-on-empty-test-suite \
--fail-on-warning \ --fail-on-warning \
@@ -99,7 +99,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
composer test -- --colors=never \ composer test -- --colors=never \
--configuration=phpunit-installer.xml \ --configuration=tests/phpunit-installer.xml \
--testsuite='Installer Integration' \ --testsuite='Installer Integration' \
--fail-on-empty-test-suite \ --fail-on-empty-test-suite \
--fail-on-warning --fail-on-warning
@@ -10,7 +10,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'scripts/ss_juniper_operating.php' - 'scripts/ss_juniper_operating.php'
- 'phpunit-juniper-operating.xml' - 'tests/phpunit-juniper-operating.xml'
- 'tests/Unit/DataCollection/Scripts/JuniperOperatingTest.php' - 'tests/Unit/DataCollection/Scripts/JuniperOperatingTest.php'
pull_request: pull_request:
branches: [develop] branches: [develop]
@@ -21,7 +21,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'scripts/ss_juniper_operating.php' - 'scripts/ss_juniper_operating.php'
- 'phpunit-juniper-operating.xml' - 'tests/phpunit-juniper-operating.xml'
- 'tests/Unit/DataCollection/Scripts/JuniperOperatingTest.php' - 'tests/Unit/DataCollection/Scripts/JuniperOperatingTest.php'
workflow_dispatch: workflow_dispatch:
@@ -37,5 +37,5 @@ jobs:
uses: ./.github/workflows/script-coverage.yml uses: ./.github/workflows/script-coverage.yml
with: with:
job-name: scripts/ss_juniper_operating.php 100% coverage job-name: scripts/ss_juniper_operating.php 100% coverage
phpunit-config: phpunit-juniper-operating.xml phpunit-config: tests/phpunit-juniper-operating.xml
extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring, snmp extensions: intl, mysql, gd, ldap, gmp, xml, curl, json, mbstring, snmp
+3 -3
View File
@@ -10,7 +10,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'lib/CactiMd5FileFinder.php' - 'lib/CactiMd5FileFinder.php'
- 'phpunit-md5-finder-coverage.xml' - 'tests/phpunit-md5-finder-coverage.xml'
- 'tests/Unit/CactiMd5FileFinderTest.php' - 'tests/Unit/CactiMd5FileFinderTest.php'
pull_request: pull_request:
branches: [develop] branches: [develop]
@@ -21,7 +21,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'lib/CactiMd5FileFinder.php' - 'lib/CactiMd5FileFinder.php'
- 'phpunit-md5-finder-coverage.xml' - 'tests/phpunit-md5-finder-coverage.xml'
- 'tests/Unit/CactiMd5FileFinderTest.php' - 'tests/Unit/CactiMd5FileFinderTest.php'
workflow_dispatch: workflow_dispatch:
@@ -37,4 +37,4 @@ jobs:
uses: ./.github/workflows/script-coverage.yml uses: ./.github/workflows/script-coverage.yml
with: with:
job-name: MD5 finder 100% coverage job-name: MD5 finder 100% coverage
phpunit-config: phpunit-md5-finder-coverage.xml phpunit-config: tests/phpunit-md5-finder-coverage.xml
@@ -13,7 +13,7 @@ on:
- 'lib/CactiNotification.php' - 'lib/CactiNotification.php'
- 'lib/CactiRecipient.php' - 'lib/CactiRecipient.php'
- 'lib/api_notification.php' - 'lib/api_notification.php'
- 'phpunit-notification-coverage.xml' - 'tests/phpunit-notification-coverage.xml'
- 'tests/Unit/Core/CactiNotificationApiTest.php' - 'tests/Unit/Core/CactiNotificationApiTest.php'
pull_request: pull_request:
branches: [develop] branches: [develop]
@@ -27,7 +27,7 @@ on:
- 'lib/CactiNotification.php' - 'lib/CactiNotification.php'
- 'lib/CactiRecipient.php' - 'lib/CactiRecipient.php'
- 'lib/api_notification.php' - 'lib/api_notification.php'
- 'phpunit-notification-coverage.xml' - 'tests/phpunit-notification-coverage.xml'
- 'tests/Unit/Core/CactiNotificationApiTest.php' - 'tests/Unit/Core/CactiNotificationApiTest.php'
workflow_dispatch: workflow_dispatch:
@@ -43,4 +43,4 @@ jobs:
uses: ./.github/workflows/script-coverage.yml uses: ./.github/workflows/script-coverage.yml
with: with:
job-name: Notification API 100% coverage job-name: Notification API 100% coverage
phpunit-config: phpunit-notification-coverage.xml phpunit-config: tests/phpunit-notification-coverage.xml
+2 -2
View File
@@ -4,7 +4,7 @@ on:
pull_request: pull_request:
paths: paths:
- '**.php' - '**.php'
- 'phpunit.xml' - 'tests/phpunit.xml'
- 'tests/e2e/**' - 'tests/e2e/**'
- 'tests/Helpers/RequestCoverage.php' - 'tests/Helpers/RequestCoverage.php'
- 'tests/tools/check_changed_php_coverage.py' - 'tests/tools/check_changed_php_coverage.py'
@@ -51,7 +51,7 @@ jobs:
python3 tests/tools/test_check_changed_php_coverage.py python3 tests/tools/test_check_changed_php_coverage.py
python3 tests/tools/test_request_coverage_dispatch.py python3 tests/tools/test_request_coverage_dispatch.py
python3 tests/tools/check_changed_php_coverage.py --base "$BASE_COMMIT" \ python3 tests/tools/check_changed_php_coverage.py --base "$BASE_COMMIT" \
--prepare-config phpunit.xml --output-config phpunit-changed.xml --prepare-config tests/phpunit.xml --output-config phpunit-changed.xml
- name: Exercise unit and integration contracts with statement coverage - name: Exercise unit and integration contracts with statement coverage
env: env:
XDEBUG_MODE: coverage XDEBUG_MODE: coverage
+3 -3
View File
@@ -9,7 +9,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'lib/CactiProcessLock.php' - 'lib/CactiProcessLock.php'
- 'phpunit-process-lock.xml' - 'tests/phpunit-process-lock.xml'
- 'tests/Unit/Core/CactiProcessLockTest.php' - 'tests/Unit/Core/CactiProcessLockTest.php'
pull_request: pull_request:
branches: [develop] branches: [develop]
@@ -19,7 +19,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'lib/CactiProcessLock.php' - 'lib/CactiProcessLock.php'
- 'phpunit-process-lock.xml' - 'tests/phpunit-process-lock.xml'
- 'tests/Unit/Core/CactiProcessLockTest.php' - 'tests/Unit/Core/CactiProcessLockTest.php'
workflow_dispatch: workflow_dispatch:
@@ -60,7 +60,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
include/vendor/bin/pest \ include/vendor/bin/pest \
--configuration=phpunit-process-lock.xml \ --configuration=tests/phpunit-process-lock.xml \
--coverage \ --coverage \
--coverage-text \ --coverage-text \
--min=100 --min=100
+1 -1
View File
@@ -169,7 +169,7 @@ jobs:
- name: Run Pest with coverage - name: Run Pest with coverage
run: | run: |
set -euo pipefail set -euo pipefail
include/vendor/bin/pest --display-warnings --coverage-clover=coverage.xml \ include/vendor/bin/pest --configuration=tests/phpunit.xml --display-warnings --coverage-clover=coverage.xml \
--coverage-text --testsuite=Unit,Integration | tee coverage-summary.txt --coverage-text --testsuite=Unit,Integration | tee coverage-summary.txt
- name: Enforce minimum statement coverage - name: Enforce minimum statement coverage
@@ -9,7 +9,7 @@ on:
- 'composer.lock' - 'composer.lock'
- 'lib/rrd_graph_item.php' - 'lib/rrd_graph_item.php'
- 'lib/rrd.php' - 'lib/rrd.php'
- 'phpunit-rrd-graph-item.xml' - 'tests/phpunit-rrd-graph-item.xml'
- 'tests/Coverage/RrdGraphItemCoverageTest.php' - 'tests/Coverage/RrdGraphItemCoverageTest.php'
- 'tests/Unit/RrdGraphItemFieldContractTest.php' - 'tests/Unit/RrdGraphItemFieldContractTest.php'
pull_request: pull_request:
@@ -20,7 +20,7 @@ on:
- 'composer.lock' - 'composer.lock'
- 'lib/rrd_graph_item.php' - 'lib/rrd_graph_item.php'
- 'lib/rrd.php' - 'lib/rrd.php'
- 'phpunit-rrd-graph-item.xml' - 'tests/phpunit-rrd-graph-item.xml'
- 'tests/Coverage/RrdGraphItemCoverageTest.php' - 'tests/Coverage/RrdGraphItemCoverageTest.php'
- 'tests/Unit/RrdGraphItemFieldContractTest.php' - 'tests/Unit/RrdGraphItemFieldContractTest.php'
workflow_dispatch: workflow_dispatch:
@@ -62,7 +62,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
include/vendor/bin/pest \ include/vendor/bin/pest \
--configuration=phpunit-rrd-graph-item.xml \ --configuration=tests/phpunit-rrd-graph-item.xml \
--coverage \ --coverage \
--coverage-text \ --coverage-text \
--min=100 --min=100
+3 -3
View File
@@ -9,7 +9,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'lib/snmp.php' - 'lib/snmp.php'
- 'phpunit-snmp.xml' - 'tests/phpunit-snmp.xml'
- 'tests/Unit/DataCollection/Snmp/SnmpCoverageTest.php' - 'tests/Unit/DataCollection/Snmp/SnmpCoverageTest.php'
- 'tests/Unit/DataCollection/Snmp/SnmpSessionErrorLoggingTest.php' - 'tests/Unit/DataCollection/Snmp/SnmpSessionErrorLoggingTest.php'
- 'tests/fixtures/snmp-coverage/**' - 'tests/fixtures/snmp-coverage/**'
@@ -22,7 +22,7 @@ on:
- 'composer.json' - 'composer.json'
- 'composer.lock' - 'composer.lock'
- 'lib/snmp.php' - 'lib/snmp.php'
- 'phpunit-snmp.xml' - 'tests/phpunit-snmp.xml'
- 'tests/Unit/DataCollection/Snmp/SnmpCoverageTest.php' - 'tests/Unit/DataCollection/Snmp/SnmpCoverageTest.php'
- 'tests/Unit/DataCollection/Snmp/SnmpSessionErrorLoggingTest.php' - 'tests/Unit/DataCollection/Snmp/SnmpSessionErrorLoggingTest.php'
- 'tests/fixtures/snmp-coverage/**' - 'tests/fixtures/snmp-coverage/**'
@@ -90,7 +90,7 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
include/vendor/bin/pest --colors=never \ include/vendor/bin/pest --colors=never \
--configuration=phpunit-snmp.xml \ --configuration=tests/phpunit-snmp.xml \
--coverage \ --coverage \
--coverage-text \ --coverage-text \
--min=100 --min=100
+1 -1
View File
@@ -149,7 +149,7 @@ jobs:
run: composer update --prefer-dist --no-progress --no-interaction run: composer update --prefer-dist --no-progress --no-interaction
- name: Run unit tests - name: Run unit tests
run: include/vendor/bin/pest --display-warnings --testsuite=Unit run: include/vendor/bin/pest --configuration=tests/phpunit.xml --display-warnings --testsuite=Unit
check: check:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
+2 -2
View File
@@ -89,9 +89,9 @@
"hardening-patterns": "php tests/tools/check_hardening_patterns.php", "hardening-patterns": "php tests/tools/check_hardening_patterns.php",
"vendor-policy": "php tests/tools/check_vendor_policy.php", "vendor-policy": "php tests/tools/check_vendor_policy.php",
"php-cs-fixit": "php-cs-fixer fix ", "php-cs-fixit": "php-cs-fixer fix ",
"test:cli-coverage": "@php include/vendor/bin/pest --configuration=phpunit-cli-coverage.xml --coverage --coverage-text --min=100", "test:cli-coverage": "@php include/vendor/bin/pest --configuration=tests/phpunit-cli-coverage.xml --coverage --coverage-text --min=100",
"install-hooks": "bash -c 'install -m 755 tests/tools/pre-commit \"$(git rev-parse --git-path hooks/pre-commit)\"'", "install-hooks": "bash -c 'install -m 755 tests/tools/pre-commit \"$(git rev-parse --git-path hooks/pre-commit)\"'",
"test": "include/vendor/bin/pest --display-warnings", "test": "include/vendor/bin/pest --configuration=tests/phpunit.xml --display-warnings",
"sink-guard": "bash tests/security/verify_sink_inventory.sh", "sink-guard": "bash tests/security/verify_sink_inventory.sh",
"hotspot-guard": "bash tests/security/verify_architectural_hotspots.sh", "hotspot-guard": "bash tests/security/verify_architectural_hotspots.sh",
"changelog": "python3 .github/scripts/check-changelog.py", "changelog": "python3 .github/scripts/check-changelog.py",
-17
View File
@@ -1,17 +0,0 @@
<phpunit bootstrap="include/vendor/autoload.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<source>
<include>
<file>lib/api_automation_tools.php</file>
</include>
</source>
<testsuites>
<testsuite name="API automation tools coverage">
<file>tests/Coverage/ApiAutomationToolsCoverageTest.php</file>
<file>tests/Unit/Security/SqlInjection/AutomationPreparedInClauseTest.php</file>
</testsuite>
</testsuites>
</phpunit>
-14
View File
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<testsuites>
<testsuite name="CDEF database integration">
<file>tests/integration/CdefDatabaseIntegrationTest.php</file>
<file>tests/integration/CdefConsumerIntegrationTest.php</file>
<file>tests/integration/CdefRepairContractTest.php</file>
</testsuite>
</testsuites>
</phpunit>
-17
View File
@@ -1,17 +0,0 @@
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<source>
<include>
<directory suffix=".php">lib/Console</directory>
</include>
</source>
<testsuites>
<testsuite name="CLI coverage">
<file>tests/Unit/Core/Cli/CactiApplicationTest.php</file>
<file>tests/Unit/Core/Cli/CactiEntrypointSecurityTest.php</file>
</testsuite>
</testsuites>
</phpunit>
-23
View File
@@ -1,23 +0,0 @@
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<source>
<include>
<file>lib/csrf.php</file>
</include>
</source>
<testsuites>
<testsuite name="CSRF coverage">
<file>tests/Unit/Security/Csrf/CactiCsrfGuardLegacyTest.php</file>
<file>tests/Unit/Security/Csrf/CactiCsrfGuardTest.php</file>
<file>tests/Unit/Security/Csrf/CactiCsrfRewriteTest.php</file>
<file>tests/Unit/Security/Csrf/CsrfBootstrapOrderTest.php</file>
<file>tests/Unit/Security/Csrf/CsrfFacadeTest.php</file>
<file>tests/Unit/Security/Csrf/CsrfScriptAssetTest.php</file>
<file>tests/Unit/Security/Csrf/CsrfVendorTest.php</file>
<file>tests/Unit/Security/Csrf/CsrfSecretNotTrackedTest.php</file>
</testsuite>
</testsuites>
</phpunit>
-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap-unit.php" colors="false" beStrictAboutOutputDuringTests="false">
<testsuites>
<testsuite name="EntitySensor">
<file>tests/Unit/DataCollection/Scripts/EntitySensorTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<file>scripts/ss_entity_sensor.php</file>
</include>
</source>
</phpunit>
-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap-unit.php" colors="false" beStrictAboutOutputDuringTests="false">
<testsuites>
<testsuite name="F5Cpu">
<file>tests/Unit/DataCollection/Scripts/F5CpuTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<file>scripts/ss_f5_cpu.php</file>
</include>
</source>
</phpunit>
-27
View File
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<testsuites>
<testsuite name="Installer Unit">
<directory>tests/Unit/Installer</directory>
<file>tests/Unit/Security/Csrf/InstallerCsrfRecoveryTest.php</file>
<!-- Covers the lib/utility.php MySQL capability helpers that the installer's recommendations step relies on. -->
<file>tests/Unit/Ui/Utility/MysqlCapabilityMatrixTest.php</file>
</testsuite>
<testsuite name="Installer Integration">
<file>tests/integration/InstallerComposerContractTest.php</file>
<file>tests/integration/InstallerVendorRefreshContractTest.php</file>
<file>tests/integration/Issue7343InstallerCsrfRecoveryIntegrationTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<file>lib/installer.php</file>
<file>install/functions.php</file>
<file>lib/utility.php</file>
</include>
</source>
</phpunit>
-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap-unit.php" colors="false" beStrictAboutOutputDuringTests="false">
<testsuites>
<testsuite name="JuniperOperating">
<file>tests/Unit/DataCollection/Scripts/JuniperOperatingTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<file>scripts/ss_juniper_operating.php</file>
</include>
</source>
</phpunit>
-19
View File
@@ -1,19 +0,0 @@
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<source>
<include>
<file>lib/CactiEmailChannel.php</file>
<file>lib/CactiNotification.php</file>
<file>lib/CactiRecipient.php</file>
<file>lib/api_notification.php</file>
</include>
</source>
<testsuites>
<testsuite name="Notification API coverage">
<file>tests/Unit/Core/CactiNotificationApiTest.php</file>
</testsuite>
</testsuites>
</phpunit>
@@ -56,7 +56,7 @@
* *
* Neither of these depends on POLLER_ID, which the shared Pest process may * Neither of these depends on POLLER_ID, which the shared Pest process may
* already have pinned to 1 via a prior test file's UnitStubs.php include * already have pinned to 1 via a prior test file's UnitStubs.php include
* (HandOff runs after Unit per phpunit.xml's testsuite order, so it always * (HandOff runs after Unit per tests/phpunit.xml's testsuite order, so it always
* has been in a full-suite run). * has been in a full-suite run).
* *
* Docker fixture: set CACTI_HANDOFF_MYSQL_HOST/_PORT/_USER/_PASS/_DB to * Docker fixture: set CACTI_HANDOFF_MYSQL_HOST/_PORT/_USER/_PASS/_DB to
+1 -1
View File
@@ -19,7 +19,7 @@
* db_execute_prepared()/db_fetch_row_prepared()/db_fetch_cell_prepared()/ * db_execute_prepared()/db_fetch_row_prepared()/db_fetch_cell_prepared()/
* db_fetch_assoc_prepared()/db_table_exists() with no explicit connection, * db_fetch_assoc_prepared()/db_table_exists() with no explicit connection,
* so exercising them means stubbing those global functions. PHP cannot * so exercising them means stubbing those global functions. PHP cannot
* redeclare an already-defined function, and phpunit.xml now runs Unit and * redeclare an already-defined function, and tests/phpunit.xml now runs Unit and
* Integration in a single process (#7497) -- once any Unit test that * Integration in a single process (#7497) -- once any Unit test that
* requires lib/database.php (e.g. DbExecutePreparedTest) loads first, the * requires lib/database.php (e.g. DbExecutePreparedTest) loads first, the
* *real* db_* functions win the race for the rest of the process, and any * *real* db_* functions win the race for the rest of the process, and any
+17
View File
@@ -0,0 +1,17 @@
<phpunit bootstrap="../include/vendor/autoload.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<source>
<include>
<file>../lib/api_automation_tools.php</file>
</include>
</source>
<testsuites>
<testsuite name="API automation tools coverage">
<file>../tests/Coverage/ApiAutomationToolsCoverageTest.php</file>
<file>../tests/Unit/Security/SqlInjection/AutomationPreparedInClauseTest.php</file>
</testsuite>
</testsuites>
</phpunit>
@@ -1,17 +1,17 @@
<phpunit bootstrap="include/vendor/autoload.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../include/vendor/autoload.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<source> <source>
<include> <include>
<file>lib/audit.php</file> <file>../lib/audit.php</file>
</include> </include>
</source> </source>
<testsuites> <testsuites>
<testsuite name="Database audit coverage"> <testsuite name="Database audit coverage">
<file>tests/Unit/Database/AuditDatabaseMissingTableTest.php</file> <file>../tests/Unit/Database/AuditDatabaseMissingTableTest.php</file>
<file>tests/Unit/Installer/InstallerSchemaValidationTest.php</file> <file>../tests/Unit/Installer/InstallerSchemaValidationTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<testsuites>
<testsuite name="CDEF database integration">
<file>../tests/integration/CdefDatabaseIntegrationTest.php</file>
<file>../tests/integration/CdefConsumerIntegrationTest.php</file>
<file>../tests/integration/CdefRepairContractTest.php</file>
</testsuite>
</testsuites>
</phpunit>
+3 -3
View File
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/Helpers/CdefCoverageBootstrap.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../tests/Helpers/CdefCoverageBootstrap.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<source> <source>
<include> <include>
<file>lib/cdef.php</file> <file>../lib/cdef.php</file>
</include> </include>
</source> </source>
<testsuites> <testsuites>
<testsuite name="CDEF coverage"> <testsuite name="CDEF coverage">
<file>tests/Coverage/CdefCoverageTest.php</file> <file>../tests/Coverage/CdefCoverageTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
+17
View File
@@ -0,0 +1,17 @@
<phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<source>
<include>
<directory suffix=".php">../lib/Console</directory>
</include>
</source>
<testsuites>
<testsuite name="CLI coverage">
<file>../tests/Unit/Core/Cli/CactiApplicationTest.php</file>
<file>../tests/Unit/Core/Cli/CactiEntrypointSecurityTest.php</file>
</testsuite>
</testsuites>
</phpunit>
@@ -1,16 +1,16 @@
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<source> <source>
<include> <include>
<file>lib/client_address.php</file> <file>../lib/client_address.php</file>
</include> </include>
</source> </source>
<testsuites> <testsuites>
<testsuite name="Client address coverage"> <testsuite name="Client address coverage">
<file>tests/Coverage/ClientAddressCoverageTest.php</file> <file>../tests/Coverage/ClientAddressCoverageTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
+23
View File
@@ -0,0 +1,23 @@
<phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<source>
<include>
<file>../lib/csrf.php</file>
</include>
</source>
<testsuites>
<testsuite name="CSRF coverage">
<file>../tests/Unit/Security/Csrf/CactiCsrfGuardLegacyTest.php</file>
<file>../tests/Unit/Security/Csrf/CactiCsrfGuardTest.php</file>
<file>../tests/Unit/Security/Csrf/CactiCsrfRewriteTest.php</file>
<file>../tests/Unit/Security/Csrf/CsrfBootstrapOrderTest.php</file>
<file>../tests/Unit/Security/Csrf/CsrfFacadeTest.php</file>
<file>../tests/Unit/Security/Csrf/CsrfScriptAssetTest.php</file>
<file>../tests/Unit/Security/Csrf/CsrfVendorTest.php</file>
<file>../tests/Unit/Security/Csrf/CsrfSecretNotTrackedTest.php</file>
</testsuite>
</testsuites>
</phpunit>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="../tests/bootstrap-unit.php" colors="false" beStrictAboutOutputDuringTests="false">
<testsuites>
<testsuite name="EntitySensor">
<file>../tests/Unit/DataCollection/Scripts/EntitySensorTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<file>../scripts/ss_entity_sensor.php</file>
</include>
</source>
</phpunit>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="../tests/bootstrap-unit.php" colors="false" beStrictAboutOutputDuringTests="false">
<testsuites>
<testsuite name="F5Cpu">
<file>../tests/Unit/DataCollection/Scripts/F5CpuTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<file>../scripts/ss_f5_cpu.php</file>
</include>
</source>
</phpunit>
@@ -1,17 +1,17 @@
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<source> <source>
<include> <include>
<file>lib/CactiForm.php</file> <file>../lib/CactiForm.php</file>
</include> </include>
</source> </source>
<testsuites> <testsuites>
<testsuite name="Form coverage"> <testsuite name="Form coverage">
<file>tests/Unit/CactiFormTest.php</file> <file>../tests/Unit/CactiFormTest.php</file>
<file>tests/integration/CactiFormIntegrationTest.php</file> <file>../tests/integration/CactiFormIntegrationTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<testsuites>
<testsuite name="Installer Unit">
<directory>../tests/Unit/Installer</directory>
<file>../tests/Unit/Security/Csrf/InstallerCsrfRecoveryTest.php</file>
<!-- Covers the lib/utility.php MySQL capability helpers that the installer's recommendations step relies on. -->
<file>../tests/Unit/Ui/Utility/MysqlCapabilityMatrixTest.php</file>
</testsuite>
<testsuite name="Installer Integration">
<file>../tests/integration/InstallerComposerContractTest.php</file>
<file>../tests/integration/InstallerVendorRefreshContractTest.php</file>
<file>../tests/integration/Issue7343InstallerCsrfRecoveryIntegrationTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<file>../lib/installer.php</file>
<file>../install/functions.php</file>
<file>../lib/utility.php</file>
</include>
</source>
</phpunit>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="../tests/bootstrap-unit.php" colors="false" beStrictAboutOutputDuringTests="false">
<testsuites>
<testsuite name="JuniperOperating">
<file>../tests/Unit/DataCollection/Scripts/JuniperOperatingTest.php</file>
</testsuite>
</testsuites>
<source>
<include>
<file>../scripts/ss_juniper_operating.php</file>
</include>
</source>
</phpunit>
@@ -1,16 +1,16 @@
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<source> <source>
<include> <include>
<file>lib/CactiMd5FileFinder.php</file> <file>../lib/CactiMd5FileFinder.php</file>
</include> </include>
</source> </source>
<testsuites> <testsuites>
<testsuite name="MD5 finder coverage"> <testsuite name="MD5 finder coverage">
<file>tests/Unit/CactiMd5FileFinderTest.php</file> <file>../tests/Unit/CactiMd5FileFinderTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
+19
View File
@@ -0,0 +1,19 @@
<phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php>
<ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php>
<source>
<include>
<file>../lib/CactiEmailChannel.php</file>
<file>../lib/CactiNotification.php</file>
<file>../lib/CactiRecipient.php</file>
<file>../lib/api_notification.php</file>
</include>
</source>
<testsuites>
<testsuite name="Notification API coverage">
<file>../tests/Unit/Core/CactiNotificationApiTest.php</file>
</testsuite>
</testsuites>
</phpunit>
@@ -1,16 +1,16 @@
<phpunit bootstrap="include/vendor/autoload.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../include/vendor/autoload.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<source> <source>
<include> <include>
<file>lib/CactiProcessLock.php</file> <file>../lib/CactiProcessLock.php</file>
</include> </include>
</source> </source>
<testsuites> <testsuites>
<testsuite name="Process lock coverage"> <testsuite name="Process lock coverage">
<file>tests/Unit/Core/CactiProcessLockTest.php</file> <file>../tests/Unit/Core/CactiProcessLockTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
@@ -1,17 +1,17 @@
<phpunit bootstrap="include/vendor/autoload.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../include/vendor/autoload.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<source> <source>
<include> <include>
<file>lib/rrd_graph_item.php</file> <file>../lib/rrd_graph_item.php</file>
</include> </include>
</source> </source>
<testsuites> <testsuites>
<testsuite name="RRD graph item field contract coverage"> <testsuite name="RRD graph item field contract coverage">
<file>tests/Coverage/RrdGraphItemCoverageTest.php</file> <file>../tests/Coverage/RrdGraphItemCoverageTest.php</file>
<file>tests/Unit/RrdGraphItemFieldContractTest.php</file> <file>../tests/Unit/RrdGraphItemFieldContractTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
+3 -3
View File
@@ -1,16 +1,16 @@
<phpunit bootstrap="include/vendor/autoload.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../include/vendor/autoload.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<source> <source>
<include> <include>
<file>lib/snmp.php</file> <file>../lib/snmp.php</file>
</include> </include>
</source> </source>
<testsuites> <testsuites>
<testsuite name="SNMP coverage"> <testsuite name="SNMP coverage">
<file>tests/Unit/DataCollection/Snmp/SnmpCoverageTest.php</file> <file>../tests/Unit/DataCollection/Snmp/SnmpCoverageTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
+7 -7
View File
@@ -1,26 +1,26 @@
<phpunit bootstrap="tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false"> <phpunit bootstrap="../tests/bootstrap-unit.php" beStrictAboutOutputDuringTests="false">
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<env name="CACTI_TEST_BOOTSTRAP" value="1"/> <env name="CACTI_TEST_BOOTSTRAP" value="1"/>
</php> </php>
<testsuites> <testsuites>
<testsuite name="Unit"> <testsuite name="Unit">
<directory>./tests/Unit</directory> <directory>.././tests/Unit</directory>
<!-- Defines dedicated SNMP stubs and must only run via phpunit-snmp.xml. --> <!-- Defines dedicated SNMP stubs and must only run via phpunit-snmp.xml. -->
<exclude>./tests/Unit/DataCollection/Snmp/SnmpCoverageTest.php</exclude> <exclude>.././tests/Unit/DataCollection/Snmp/SnmpCoverageTest.php</exclude>
</testsuite> </testsuite>
<testsuite name="Integration"> <testsuite name="Integration">
<directory>./tests/integration</directory> <directory>.././tests/integration</directory>
<!-- Uses dedicated CDEF database fixtures and runs via phpunit-cdef-integration.xml. --> <!-- Uses dedicated CDEF database fixtures and runs via phpunit-cdef-integration.xml. -->
<exclude>./tests/integration/CdefDatabaseIntegrationTest.php</exclude> <exclude>.././tests/integration/CdefDatabaseIntegrationTest.php</exclude>
</testsuite> </testsuite>
<testsuite name="HandOff"> <testsuite name="HandOff">
<directory>./tests/HandOff</directory> <directory>.././tests/HandOff</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<source> <source>
<include> <include>
<directory>./lib</directory> <directory>.././lib</directory>
</include> </include>
</source> </source>
</phpunit> </phpunit>
+14 -1
View File
@@ -6,6 +6,7 @@ Copyright (C) 2004-2026 The Cacti Group. GPL-2.0-or-later.
import argparse import argparse
import hashlib import hashlib
import json import json
import os
from pathlib import Path from pathlib import Path
import re import re
import subprocess import subprocess
@@ -42,13 +43,25 @@ def added_lines(base, root):
def prepare_config(config, output, changed): def prepare_config(config, output, changed):
"""Keep the test suite, but include every changed production PHP file.""" """Keep the test suite, but include every changed production PHP file."""
tree = ET.parse(config) tree = ET.parse(config)
config_dir = Path(config).resolve().parent
output_dir = Path(output).resolve().parent
for element in tree.iter():
for attribute in ('bootstrap', 'cacheDirectory', 'cacheResultFile',
'outputDirectory', 'outputFile', 'target'):
value = element.get(attribute)
if value and not Path(value).is_absolute():
element.set(attribute, os.path.relpath(config_dir / value, output_dir))
if element.tag in ('file', 'directory', 'exclude') and element.text:
value = element.text
if not Path(value).is_absolute():
element.text = os.path.relpath(config_dir / value, output_dir)
source = tree.getroot().find('source') source = tree.getroot().find('source')
if source is None: if source is None:
source = ET.SubElement(tree.getroot(), 'source') source = ET.SubElement(tree.getroot(), 'source')
source.clear() source.clear()
include = ET.SubElement(source, 'include') include = ET.SubElement(source, 'include')
for name in sorted(changed): for name in sorted(changed):
ET.SubElement(include, 'file').text = name ET.SubElement(include, 'file').text = os.path.relpath(Path.cwd() / name, output_dir)
ET.indent(tree, space=' ') ET.indent(tree, space=' ')
tree.write(output, encoding='utf-8', xml_declaration=True) tree.write(output, encoding='utf-8', xml_declaration=True)
+1 -1
View File
@@ -19,4 +19,4 @@ docker build \
docker run --rm \ docker run --rm \
--env XDEBUG_MODE="${XDEBUG_MODE:-off}" \ --env XDEBUG_MODE="${XDEBUG_MODE:-off}" \
"${test_image}" \ "${test_image}" \
include/vendor/bin/pest --display-warnings "$@" include/vendor/bin/pest --configuration=tests/phpunit.xml --display-warnings "$@"
+20 -2
View File
@@ -70,8 +70,26 @@ class ChangedPhpCoverageTest(unittest.TestCase):
tree = ET.parse(output) tree = ET.parse(output)
self.assertEqual(tree.getroot().attrib['bootstrap'], 'tests/bootstrap-unit.php') self.assertEqual(tree.getroot().attrib['bootstrap'], 'tests/bootstrap-unit.php')
self.assertEqual(tree.findtext('testsuites/testsuite/directory'), 'tests/Unit') self.assertEqual(tree.findtext('testsuites/testsuite/directory'), 'tests/Unit')
self.assertEqual([file.text for file in tree.findall('source/include/file')], self.assertEqual([(output.parent / file.text).resolve() for file in tree.findall('source/include/file')],
['lib/plugins.php', 'plugins.php']) [(Path.cwd() / name).resolve() for name in ['lib/plugins.php', 'plugins.php']])
def test_relocated_config_keeps_bootstrap_and_test_paths(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
tests = root / 'tests'
tests.mkdir()
config = tests / 'phpunit.xml'
output = root / 'phpunit-changed.xml'
config.write_text('<phpunit bootstrap="../tests/bootstrap-unit.php">'
'<testsuites><testsuite name="Unit">'
'<directory>../tests/Unit</directory>'
'</testsuite></testsuites></phpunit>')
GATE.prepare_config(config, output, {'lib/plugins.php': {3}})
tree = ET.parse(output)
self.assertEqual((output.parent / tree.getroot().get('bootstrap')).resolve(),
(tests / 'bootstrap-unit.php').resolve())
self.assertEqual((output.parent / tree.findtext('testsuites/testsuite/directory')).resolve(),
(tests / 'Unit').resolve())
def test_request_reports_require_matching_source_and_keep_uncovered_lines(self): def test_request_reports_require_matching_source_and_keep_uncovered_lines(self):
with tempfile.TemporaryDirectory() as directory: with tempfile.TemporaryDirectory() as directory: