cms
cms copied to clipboard
Addon `directory()` is null when testing an addon's views
Bug description
I have an addon that I'm writing tests for, and the functionality requires a custom view, which I have in the addons resources/views folder. This view works perfectly when addon is loaded normally, but when I'm testing, the addon's view namespace is not registered.
Specifically, the $this->getAddon()->directory() in AddonServiceProvider's bootViews is null.
You can't set directory in the TestCase manifest because directory is NOT in the inclusion list in AddonRepository when it "creates" the addon.
For some reason the provider is null here:

How to reproduce
- Create an addon with views.
- try to access those views in a test
Logs
No response
Environment
Environment
Application Name: Statamic
Laravel Version: 9.52.5
PHP Version: 8.2.4
Composer Version: 2.5.5
Environment: local
Debug Mode: ENABLED
URL: transform.test
Maintenance Mode: OFF
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: daily
Mail: smtp
Queue: redis
Session: file
Statamic
Addons: 11
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 3.4.7 PRO
Statamic Addons
aryehraber/statamic-captcha: 1.9.1
edalzell/forma: 1.3.0
jonassiewertsen/statamic-jobs: 1.3.0
jonassiewertsen/statamic-livewire: 2.11.0
statamic/seo-pro: 4.0.1
transformstudios/events: 4.2.0
transformstudios/front: dev-feature/support-generic-notifications
transformstudios/github: dev-main
transformstudios/review: 3.8.1
transformstudios/simple: 3.6.0
transformstudios/uptime: dev-feature/other-events
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
None
Additional details
No response
What does your addon's TestCase look like?
This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.
It looks like this issue has been fixed in v5, thanks to #9593.