1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace Maatwebsite\Excel\Tests\Concerns;
- use Maatwebsite\Excel\Tests\Data\Stubs\QueuedExport;
- use Maatwebsite\Excel\Tests\Data\Stubs\SheetWith100Rows;
- use Maatwebsite\Excel\Tests\TestCase;
- class FromCollectionTest extends TestCase
- {
- /**
- * @test
- */
- public function can_export_from_collection()
- {
- $export = new SheetWith100Rows('A');
- $response = $export->store('from-collection-store.xlsx');
- $this->assertTrue($response);
- $contents = $this->readAsArray(__DIR__ . '/../Data/Disks/Local/from-collection-store.xlsx', 'Xlsx');
- $this->assertEquals($export->collection()->toArray(), $contents);
- }
- /**
- * @test
- */
- public function can_export_with_multiple_sheets_from_collection()
- {
- $export = new QueuedExport();
- $response = $export->store('multiple-sheets-collection-store.xlsx');
- $this->assertTrue($response);
- foreach ($export->sheets() as $sheetIndex => $sheet) {
- $spreadsheet = $this->read(
- __DIR__ . '/../Data/Disks/Local/multiple-sheets-collection-store.xlsx',
- 'Xlsx'
- );
- $worksheet = $spreadsheet->getSheet($sheetIndex);
- $this->assertEquals($sheet->collection()->toArray(), $worksheet->toArray());
- $this->assertEquals($sheet->title(), $worksheet->getTitle());
- }
- }
- }
|