From 2dca2ab5a731275bb9d05a5e59350936588bf78d Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Sun, 26 Jan 2020 21:42:09 +0800 Subject: [PATCH] [5.x] Add ProvidesBrowser::getCallerName(); This would allow better support when we need to use laravel/dusk outside of PHPUnit\Framework\TestCase. Signed-off-by: Mior Muhammad Zaki --- src/Concerns/ProvidesBrowser.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Concerns/ProvidesBrowser.php b/src/Concerns/ProvidesBrowser.php index c7a7d1f02..d08ae5a45 100644 --- a/src/Concerns/ProvidesBrowser.php +++ b/src/Concerns/ProvidesBrowser.php @@ -141,7 +141,7 @@ protected function captureFailuresFor($browsers) $browser->fitContent(); } - $name = str_replace('\\', '_', get_class($this)).'_'.$this->getName(false); + $name = $this->getCallerName(); $browser->screenshot('failure-'.$name.'-'.$key); }); @@ -156,7 +156,7 @@ protected function captureFailuresFor($browsers) protected function storeConsoleLogsFor($browsers) { $browsers->each(function ($browser, $key) { - $name = str_replace('\\', '_', get_class($this)).'_'.$this->getName(false); + $name = $this->getCallerName(); $browser->storeConsoleLog($name.'-'.$key); }); @@ -201,6 +201,16 @@ protected function createWebDriver() }, 50); } + /** + * Get the browser caller name. + * + * @return string + */ + protected function getCallerName() + { + return str_replace('\\', '_', get_class($this)).'_'.$this->getName(false); + } + /** * Create the RemoteWebDriver instance. *