Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

When using Components, always getting a "call to a member function collect() on null" error #50

Closed
nie7321 opened this issue Jun 13, 2019 · 0 comments

Comments

@nie7321
Copy link
Contributor

nie7321 commented Jun 13, 2019

When I use a component and a $browser->within(new MyComponent, . . .), I'm always getting an error:

    public function test_dashboard_available()
    {
        $this->browse(function (Browser $browser) {
            $browser->within((new Multiselect('#search-status-selector')), function ($browser) {
                $browser->clickOption(3);
            });
        });
    }

Resulting in:

Error: Call to a member function collect() on null

/home/vagrant/code/dusk-dashboard/src/Dusk/Concerns/MakesAssertions.php:262
/home/vagrant/code/a-nice-project/tests/Browser/Components/Bootstrap/Multiselect.php:39

I think the problem is that the Laravel\Dusk\Browser is just doing a new static() to make a Browser for the component -- it doesn't know that it needs to call setActionCollector().

I can work around the bug by passing the BrowserActionCollector through from the test case, and then calling setActionCollector myself before the component uses the browser instance, but this is kinda gross.

I'm not sure what the right way to solve this is!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants