Skip to content

Commit

Permalink
Limiting length of getCallerName return value to avoid issue when sto…
Browse files Browse the repository at this point in the history
…ring 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
  • Loading branch information
lk77 authored Nov 14, 2023
1 parent fa6c39f commit 99df89a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Concerns/ProvidesBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected function getCallerName()
? $this->name()
: $this->getName(false); // @phpstan-ignore-line

return str_replace('\\', '_', get_class($this)).'_'.$name;
return str_replace('\\', '_', substr(get_class($this), 0, 70)).'_'.substr($name, 0, 70);
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/Unit/ProvidesBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ public function test_store_console_logs_for()
$this->storeConsoleLogsFor($browsers);
}

public function test_truncate_test_name_where_that_name_is_too_long_and_might_cause_issues()
{
$browser = m::mock(stdClass::class);
$browser->shouldReceive('storeConsoleLog')->with(
'Laravel_Dusk_Tests_Unit_ProvidesBrowserTest_test_truncate_test_name_where_that_name_is_too_long_and_might_cause_is-0'
);
$browsers = collect([$browser]);

$this->storeConsoleLogsFor($browsers);
}

public static function testData()
{
return [
Expand Down

0 comments on commit 99df89a

Please sign in to comment.