Skip to content

Addon directory() is null when testing an addon's views #7947

@edalzell

Description

@edalzell

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:
CleanShot 2023-04-18 at 15 50 05@2x

How to reproduce

  1. Create an addon with views.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions