Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 9 additions & 74 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ on:
jobs:
tests:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
image: mysql:8
env:
MYSQL_DATABASE: laravel_excel
MYSQL_ALLOW_EMPTY_PASSWORD: yes
Expand All @@ -22,11 +22,12 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: false
matrix:
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
laravel: [12, 11, 10, 9, 8, 7, 6, 5.8]
dependency-version: [prefer-stable]
os: [ubuntu-latest]
php: [ 8.1, 8.2, 8.3, 8.4, 8.5 ]
laravel: [ 12, 11, 10 ]
dependency-version: [ prefer-stable ]
os: [ ubuntu-latest ]
include:
- laravel: 12
scout: 10.*
Expand All @@ -37,76 +38,15 @@ jobs:
- laravel: 10
scout: 10.*
testbench: 8.*
- laravel: 9
scout: 9.*
testbench: 7.*
- laravel: 8
scout: 8.*
testbench: 6.*
- laravel: 7
scout: 7.2.*
testbench: 5.*
- laravel: 6
scout: 7.1.*
testbench: 4.*
- laravel: 5.8
scout: 7.1.*
testbench: 3.8.*
exclude:
- laravel: 12
php: 8.1
- laravel: 12
php: 8.0
- laravel: 12
php: 7.4
- laravel: 11
php: 8.1
- laravel: 11
php: 8.0
- laravel: 11
php: 7.4
- laravel: 10
php: 8.0
- laravel: 10
php: 7.4
- laravel: 10
php: 8.4
- laravel: 9
php: 7.4
- laravel: 9
php: 8.4
- laravel: 8
php: 8.4
- laravel: 7
php: 8.0
- laravel: 7
php: 8.1
- laravel: 7
php: 8.2
- laravel: 7
php: 8.3
- laravel: 7
php: 8.4
- laravel: 6
php: 8.0
- laravel: 6
php: 8.1
- laravel: 6
php: 8.2
- laravel: 6
php: 8.3
- laravel: 6
php: 8.4
- laravel: 5.8
php: 8.0
- laravel: 5.8
php: 8.1
- laravel: 5.8
php: 8.2
- laravel: 5.8
php: 8.3
- laravel: 5.8
php: 8.4
- laravel: 10
php: 8.5

name: PHP${{ matrix.php }} - L${{ matrix.laravel }}

Expand All @@ -132,11 +72,6 @@ jobs:
composer require "laravel/framework:${{ matrix.laravel }}.*" "orchestra/testbench:${{ matrix.testbench }}" "laravel/scout:${{ matrix.scout }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --no-interaction

- name: Install legacy factories
run: |
composer require "laravel/legacy-factories" --no-interaction
if: "matrix.laravel >= 8"

- name: Execute tests
run: vendor/bin/phpunit --testdox --configuration phpunit.xml.dist
env:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ composer.lock
.DS_Store
.idea
phpunit.xml
.phpunit.result.cache
.phpunit.result.cache
/.phpunit.cache
1 change: 0 additions & 1 deletion .phpunit.cache/test-results

This file was deleted.

10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
],
"require": {
"ext-json": "*",
"php": "^7.0||^8.0",
"phpoffice/phpspreadsheet": "^1.30.0",
"illuminate/support": "5.8.*||^6.0||^7.0||^8.0||^9.0||^10.0||^11.0||^12.0",
"php": "^8.1",
"phpoffice/phpspreadsheet": "^5.1",
"illuminate/support": "^10.0||^11.0||^12.0",
"psr/simple-cache": "^1.0||^2.0||^3.0",
"composer/semver": "^3.3"
},
"require-dev": {
"orchestra/testbench": "^6.0||^7.0||^8.0||^9.0||^10.0",
"orchestra/testbench": "^8.0||^9.0||^10.0",
"predis/predis": "^1.1",
"laravel/scout": "^7.0||^8.0||^9.0||^10.0"
"laravel/scout": "^10.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultValueBinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DefaultValueBinder extends PhpSpreadsheetDefaultValueBinder
* @param mixed $value Value to bind in cell
* @return bool
*/
public function bindValue(Cell $cell, $value)
public function bindValue(Cell $cell, mixed $value): bool
{
if (is_array($value)) {
$value = \json_encode($value);
Expand Down
2 changes: 1 addition & 1 deletion src/Filters/ChunkReadFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(int $headingRow, int $startRow, int $chunkSize, stri
* @param string $worksheetName
* @return bool
*/
public function readCell($column, $row, $worksheetName = '')
public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool
{
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
return ($worksheetName === $this->worksheetName || $worksheetName === '')
Expand Down
2 changes: 1 addition & 1 deletion src/Filters/LimitFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(int $startRow, int $limit)
* @param string $worksheetName
* @return bool
*/
public function readCell($column, $row, $worksheetName = '')
public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool
{
return $row >= $this->startRow && $row <= $this->endRow;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ private function buildSheetImports($import): array
) {
$this->reader->setLoadSheetsOnly(array_keys($sheetImports));
}

if (method_exists($this->reader, 'setCreateBlankSheetIfNoneRead')) {
$this->reader->setCreateBlankSheetIfNoneRead(true);
}
}

return $sheetImports;
Expand Down
5 changes: 1 addition & 4 deletions tests/Cache/BatchCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ public function test_it_persists_to_cache_when_memory_limit_reached_on_setting_m
], $cache->getMultiple(['A1', 'A2', 'A3', 'A4', 'A5']));
}

/**
* @dataProvider defaultTTLDataProvider
*/
#[DataProvider('defaultTTLDataProvider')]
public function test_it_writes_to_cache_with_default_ttl($defaultTTL, $receivedAs)
{
Expand Down Expand Up @@ -243,7 +240,7 @@ public static function defaultTTLDataProvider(): array
* @param int|null $memoryLimit
* @return CacheInterface
*/
private function givenCache(array $memory = [], array $persisted = [], $memoryLimit = null): CacheInterface
private function givenCache(array $memory = [], array $persisted = [], ?int $memoryLimit = null): CacheInterface
{
config()->set('excel.cache.batch.memory_limit', $memoryLimit ?: 60000);

Expand Down
18 changes: 2 additions & 16 deletions tests/Concerns/FromQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,10 @@ protected function setUp(): void
parent::setUp();

$this->loadLaravelMigrations(['--database' => 'testing']);
$this->withFactories(__DIR__ . '/../Data/Stubs/Database/Factories');
$this->loadMigrationsFrom(dirname(__DIR__) . '/Data/Stubs/Database/Migrations');

$group = factory(Group::class)->create([
'name' => 'Group 1',
]);

factory(User::class)->times(100)->create()->each(function (User $user) use ($group) {
$user->groups()->save($group);
});

$group_two = factory(Group::class)->create([
'name' => 'Group 2',
]);

factory(User::class)->times(5)->create()->each(function (User $user) use ($group_two) {
$user->groups()->save($group_two);
});
User::factory()->has(Group::factory(['name' => 'Group 1']))->count(100)->create();
User::factory()->has(Group::factory(['name' => 'Group 2']))->count(5)->create();
}

public function test_can_export_from_query()
Expand Down
9 changes: 3 additions & 6 deletions tests/Concerns/FromViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@

class FromViewTest extends TestCase
{
/**
* Setup the test environment.
*/
protected function setUp(): void
{
parent::setUp();

$this->withFactories(__DIR__ . '/../Data/Stubs/Database/Factories');
$this->loadLaravelMigrations(['--database' => 'testing']);
}

public function test_can_export_from_view()
{
/** @var Collection|User[] $users */
$users = factory(User::class)->times(100)->make();
$users = User::factory()->count(100)->create();

$export = new class($users) implements FromView
{
Expand Down Expand Up @@ -75,7 +72,7 @@ public function view(): View
public function test_can_export_multiple_sheets_from_view()
{
/** @var Collection|User[] $users */
$users = factory(User::class)->times(300)->make();
$users = User::factory()->count(300)->create();

$export = new class($users) implements WithMultipleSheets
{
Expand Down
6 changes: 1 addition & 5 deletions tests/Concerns/WithColumnFormattingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Maatwebsite\Excel\Tests\Concerns;

use Carbon\Carbon;
use Composer\InstalledVersions;
use Composer\Semver\VersionParser;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
Expand Down Expand Up @@ -65,13 +63,11 @@ public function columnFormats(): array

$actual = $this->readAsArray(__DIR__ . '/../Data/Disks/Local/with-column-formatting-store.xlsx', 'Xlsx');

$legacyPhpSpreadsheet = !InstalledVersions::satisfies(new VersionParser, 'phpoffice/phpspreadsheet', '^1.28');

$expected = [
['06/03/2018', null],
['07/03/2018', null],
['08/03/2018', null],
['06/12/2021', $legacyPhpSpreadsheet ? '100 €' : '100.00 €'],
['06/12/2021', '100.00 €'],
];

$this->assertEquals($expected, $actual);
Expand Down
10 changes: 0 additions & 10 deletions tests/Concerns/WithConditionalSheetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@

class WithConditionalSheetsTest extends TestCase
{
/**
* Setup the test environment.
*/
protected function setUp(): void
{
parent::setUp();

$this->withFactories(__DIR__ . '/../Data/Stubs/Database/Factories');
}

public function test_can_select_which_sheets_will_be_imported()
{
$import = new class implements WithMultipleSheets
Expand Down
5 changes: 2 additions & 3 deletions tests/Concerns/WithCustomQuerySizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ protected function setUp(): void

$this->loadLaravelMigrations(['--database' => 'testing']);
$this->loadMigrationsFrom(dirname(__DIR__) . '/Data/Stubs/Database/Migrations');
$this->withFactories(dirname(__DIR__) . '/Data/Stubs/Database/Factories');

factory(Group::class)->times(5)->create()->each(function ($group) {
$group->users()->attach(factory(User::class)->times(rand(1, 3))->create());
Group::factory()->count(5)->create()->each(function (Group $group) {
$group->users()->attach(User::factory()->count(rand(1, 3))->create());
});

config()->set('excel.exports.chunk_size', 2);
Expand Down
Loading