Skip to content

Add PHPUnit tests for dispPlusadCancel and matchWhitelist with CI pipeline - #4

Merged
Lastorder-DC merged 3 commits into
mainfrom
copilot/add-php-test-code
Mar 20, 2026
Merged

Add PHPUnit tests for dispPlusadCancel and matchWhitelist with CI pipeline#4
Lastorder-DC merged 3 commits into
mainfrom
copilot/add-php-test-code

Conversation

Copilot AI commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

PHPUnit test coverage for ad cancellation refund logic and URL whitelist matching, with GitHub Actions CI across PHP 7.4–8.5.

Test infrastructure

  • tests/bootstrap.php — Rhymix CMS emulation layer: BaseObject, ModuleObject, Context::get/set, executeQuery, pointController::setPoint, pointModel, DB, moduleModel
  • composer.json with phpunit/phpunit: ^9.6 || ^10.5 || ^11.0 for full PHP version range
  • phpunit.xml minimal config compatible across PHPUnit 9/10/11

dispPlusadCancel tests (cancel_threshold=10%, cancel_fee=10%, ad_point=10000)

  • Auth/ownership guards: no login, ad not found, wrong owner
  • <0.5% elapsed → refund 9,000 pts (deduction: round(0.3%) + 10% fee = 10%)
  • ~10% elapsed → refund 8,000 pts (deduction: round(9.99%) + 10% fee = 20%)
  • 20% elapsed → rejected, no refund, no delete query fired

Uses large total duration (10M seconds) to make timing-sensitive assertions robust against wall-clock drift between setup and execution.

matchWhitelist tests

  • Empty/null domain_list → regex /^$/, blocks all non-empty URLs
  • Single domain → example.com allowed with any path, other domains rejected
  • Two domains (\n-separated) → both allowed, others rejected
  • Path-independent: domain determines match regardless of path/query/fragment
  • \r\n line endings handled correctly

CI workflow (.github/workflows/ci.yml)

  • Matrix: PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 8.5
  • lint job: php -l syntax check on all non-vendor PHP files
  • test job: composer install + vendor/bin/phpunit
  • Explicit permissions: contents: read

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 20, 2026 03:17
…kflow

Co-authored-by: Lastorder-DC <18280396+Lastorder-DC@users.noreply.github.com>
Co-authored-by: Lastorder-DC <18280396+Lastorder-DC@users.noreply.github.com>
Copilot AI changed the title [WIP] Add PHP test code for module functions Add PHPUnit tests for dispPlusadCancel and matchWhitelist with CI pipeline Mar 20, 2026
Copilot AI requested a review from Lastorder-DC March 20, 2026 03:19
@Lastorder-DC
Lastorder-DC marked this pull request as ready for review March 20, 2026 03:22
@Lastorder-DC
Lastorder-DC merged commit 1a184d1 into main Mar 20, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants