Skip to content

Commit 99df89a

Browse files
authored
Limiting length of getCallerName return value to avoid issue when storing logs and screenshots (#1070)
* Limiting length of getCallerName return value to avoid issue when storing logs and screenshots * Adding a test to verify that test name is truncated correctly
1 parent fa6c39f commit 99df89a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Concerns/ProvidesBrowser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ protected function getCallerName()
232232
? $this->name()
233233
: $this->getName(false); // @phpstan-ignore-line
234234

235-
return str_replace('\\', '_', get_class($this)).'_'.$name;
235+
return str_replace('\\', '_', substr(get_class($this), 0, 70)).'_'.substr($name, 0, 70);
236236
}
237237

238238
/**

tests/Unit/ProvidesBrowserTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ public function test_store_console_logs_for()
4444
$this->storeConsoleLogsFor($browsers);
4545
}
4646

47+
public function test_truncate_test_name_where_that_name_is_too_long_and_might_cause_issues()
48+
{
49+
$browser = m::mock(stdClass::class);
50+
$browser->shouldReceive('storeConsoleLog')->with(
51+
'Laravel_Dusk_Tests_Unit_ProvidesBrowserTest_test_truncate_test_name_where_that_name_is_too_long_and_might_cause_is-0'
52+
);
53+
$browsers = collect([$browser]);
54+
55+
$this->storeConsoleLogsFor($browsers);
56+
}
57+
4758
public static function testData()
4859
{
4960
return [

0 commit comments

Comments
 (0)