Add standalone PHP unit test suite (no Nextcloud checkout needed) - #399
Add standalone PHP unit test suite (no Nextcloud checkout needed)#399R0Wi wants to merge 1 commit into
Conversation
bfd9cde to
1f95468
Compare
|
Root cause: No fix exists yet anywhere in the repo for this (checked open/closed PRs — #353 fixed a similar-shaped NC-version-bump break in this same file back in February, but not this one). Proposed patch, to be applied on - use OCP\Files\Folder;
+ use OCP\Files\IUserFolder;and, at each of the 3 call sites: - /** @var Folder|MockObject */
- $userFolder = $this->createMock(Folder::class);
+ /** @var IUserFolder|MockObject */
+ $userFolder = $this->createMock(IUserFolder::class);I'm not pushing this into this PR since it's unrelated to its purpose (would be widening scope) — happy to open a dedicated fix PR if you'd like. Generated by Claude Code |
1f95468 to
8ddb7f2
Compare
Adds a second way to run tests/Unit/ that only needs `composer install`,
using the existing nextcloud/ocp dependency for OCP/NCU symbols instead
of a full Nextcloud checkout:
- tests/bootstrap.standalone.php + phpunit.standalone.xml: new bootstrap
and phpunit config, `make php-unittest-standalone`.
- Six test files that only used Test\TestCase out of habit now extend
plain PHPUnit\Framework\TestCase.
- tests/Unit/TestUtils/: an invokePrivate replacement trait, plus small
polyfills for classes nextcloud/ocp doesn't ship (OC\User\NoUserException,
OC\Notification\Notification, OCA\Files_Versions\Versions\*,
OCA\AppAPI\PublicFunctions), loaded only when not already autoloadable.
- composer.json: nextcloud/ocp ships no autoload section, so autoload-dev
adds a classmap for it plus a PSR-4 mapping for tests/Unit/.
- Seven files that touch a real, non-trivial Nextcloud implementation
(not just an interface) are excluded via #[Group('nextcloud-full')]
and keep running only under phpunit.xml inside a full Nextcloud
checkout: AppInfo/ApplicationTest, OcrProcessors/OcrProcessorFactoryTest,
composer/AutoloadTest (real OCP\AppFramework\App), Wrapper/ViewFactoryTest
(real OC\Files\View), BackgroundJobs/ProcessFileJobTest and
Listener/RegisterFlowOperationsListenerTest (real OCP\Server::get()
call chains), Notification/NotifierTest (real OC\Notification\Notification).
CI: .github/workflows/phpunit.yml's sqlite/mysql/pgsql jobs now run
`make php-integrationtest` instead of `make php-test`, since the unit
suite doesn't vary by DB backend; a new `standalone` job covers the
unit suite instead. The coverage workflow (sonarqube.yml) is untouched
and is now the only pipeline still running the full, NC-bootstrapped
unit suite. phpunit-integration.yml needed no change.
CLAUDE.md and .github/copilot-instructions.md updated accordingly.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kaif5z7SuTvEMonu4eTHjw
8ddb7f2 to
756816d
Compare
Adds a second way to run tests/Unit/ that only needs
composer install,using the existing nextcloud/ocp dependency for OCP/NCU symbols instead
of a full Nextcloud checkout:
and phpunit config,
make php-unittest-standalone.plain PHPUnit\Framework\TestCase.
polyfills for classes nextcloud/ocp doesn't ship (OC\User\NoUserException,
OC\Notification\Notification, OCA\Files_Versions\Versions*,
OCA\AppAPI\PublicFunctions), loaded only when not already autoloadable.
adds a classmap for it plus a PSR-4 mapping for tests/Unit/.
(not just an interface) are excluded via #[Group('nextcloud-full')]
and keep running only under phpunit.xml inside a full Nextcloud
checkout: AppInfo/ApplicationTest, OcrProcessors/OcrProcessorFactoryTest,
composer/AutoloadTest (real OCP\AppFramework\App), Wrapper/ViewFactoryTest
(real OC\Files\View), BackgroundJobs/ProcessFileJobTest and
Listener/RegisterFlowOperationsListenerTest (real OCP\Server::get()
call chains), Notification/NotifierTest (real OC\Notification\Notification).
CI: .github/workflows/phpunit.yml's sqlite/mysql/pgsql jobs now run
make php-integrationtestinstead ofmake php-test, since the unitsuite doesn't vary by DB backend; a new
standalonejob covers theunit suite instead. The coverage workflow (sonarqube.yml) is untouched
and is now the only pipeline still running the full, NC-bootstrapped
unit suite. phpunit-integration.yml needed no change.
CLAUDE.md and .github/copilot-instructions.md updated accordingly.
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Kaif5z7SuTvEMonu4eTHjw