Laravel-Excel
Laravel-Excel copied to clipboard
[Bug]: Excel::fake() for Excel::Store Parameters Do Not Match
Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?
- [X] Yes, it's still reproducable
What version of Laravel Excel are you using?
3.1.40
What version of Laravel are you using?
9.11.0
What version of PHP are you using?
8.1.7
Describe your issue
The method signature for Excel::store
does not match when faked, so using a named parameter for diskName
tests fail with Unknown named parameter $diskName
store($export, $filePath, $diskName = null, $writerType = null, $diskOptions = []
But the method signature for the faked Excel::store
, substituted when Excel::fake()
is called is:
store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])
$diskName <> $disk
How can the issue be reproduced?
Write some code that uses Excel::Store()
and provide it a list of named parameters:
Excel::store(
export: new CSVExport(),
filePath: "A file name.csv",
diskName: 'diskname',
writerType: \Maatwebsite\Excel\Excel::CSV,
diskOptions: ['visibility' => 'private']
)
In a test, call Excel::fake()
and run the above code
What should be the expected behaviour?
The test should not throw a Unknown named parameter $diskName parameter
error when Excel
is faked.
Please provide a PR with a suggested fix. Please note that as we support multiple PHP versions, we never intended it to be used as named parameters.
This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.
Please provide a PR with a suggested fix. Please note that as we support multiple PHP versions, we never intended it to be used as named parameters.
I'm experiencing the same problem as @LarsaSolidor. So, does this mean that we shouldn't use named parameters?