FromArrayTest.php 918 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Maatwebsite\Excel\Tests\Concerns;
  3. use Maatwebsite\Excel\Concerns\Exportable;
  4. use Maatwebsite\Excel\Concerns\FromArray;
  5. use Maatwebsite\Excel\Tests\TestCase;
  6. class FromArrayTest extends TestCase
  7. {
  8. /**
  9. * @test
  10. */
  11. public function can_export_from_array()
  12. {
  13. $export = new class implements FromArray
  14. {
  15. use Exportable;
  16. /**
  17. * @return array
  18. */
  19. public function array(): array
  20. {
  21. return [
  22. ['test', 'test'],
  23. ['test', 'test'],
  24. ];
  25. }
  26. };
  27. $response = $export->store('from-array-store.xlsx');
  28. $this->assertTrue($response);
  29. $contents = $this->readAsArray(__DIR__ . '/../Data/Disks/Local/from-array-store.xlsx', 'Xlsx');
  30. $this->assertEquals($export->array(), $contents);
  31. }
  32. }