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

Commit

Permalink
Add action collectors to scoped component browser instances
Browse files Browse the repository at this point in the history
  • Loading branch information
nie7321 committed Jun 13, 2019
1 parent c12c31e commit ba2062c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Dusk/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace BeyondCode\DuskDashboard\Dusk;

use Closure;
use BeyondCode\DuskDashboard\BrowserActionCollector;

class Browser extends \Laravel\Dusk\Browser
Expand Down Expand Up @@ -61,6 +62,30 @@ public function refresh()
return $browser;
}

/** {@inheritdoc} */
public function with($selector, Closure $callback)
{
$action_collector_callback = function ($browser) use ($callback) {
print 'Entering the wrapped callback...';
$browser->setActionCollector($this->getActionCollector());

print 'Wrapped callback invoked & updated browser!';
return $callback($browser);
};

return parent::with($selector, $action_collector_callback);
}

/** {@inheritDoc} */
public function onComponent($component, $parentResolver)
{
if ($this->getActionCollector() === null) {
$this->setActionCollector(new BrowserActionCollector('dog'));
}

parent::onComponent($component, $parentResolver);
}

public function getCurrentPageSource()
{
$this->ensurejQueryIsAvailable();
Expand Down

0 comments on commit ba2062c

Please sign in to comment.