12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace Maatwebsite\Excel\Tests\Data\Stubs;
- use Exception;
- use Illuminate\Database\Eloquent\Collection;
- use Maatwebsite\Excel\Concerns\Exportable;
- use Maatwebsite\Excel\Concerns\FromCollection;
- use Maatwebsite\Excel\Concerns\WithMapping;
- use Maatwebsite\Excel\Tests\Data\Stubs\Database\User;
- use PHPUnit\Framework\Assert;
- class QueuedExportWithFailedHook implements FromCollection, WithMapping
- {
- use Exportable;
- /**
- * @var bool
- */
- public $failed = false;
- /**
- * @return Collection
- */
- public function collection()
- {
- return collect([
- new User([
- 'firstname' => 'Patrick',
- 'lastname' => 'Brouwers',
- ]),
- ]);
- }
- /**
- * @param User $user
- * @return array
- */
- public function map($user): array
- {
- throw new Exception('we expect this');
- }
- /**
- * @param Exception $exception
- */
- public function failed(Exception $exception)
- {
- Assert::assertEquals('we expect this', $exception->getMessage());
- app()->bind('queue-has-failed', function () {
- return true;
- });
- }
- }
|