-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathCellTest.php
49 lines (35 loc) · 1.54 KB
/
CellTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Maatwebsite\Excel\Tests;
use Maatwebsite\Excel\Cell;
use Maatwebsite\Excel\Middleware\ConvertEmptyCellValuesToNull;
use Maatwebsite\Excel\Middleware\TrimCellValue;
class CellTest extends TestCase
{
public function test_can_get_cell_value()
{
config()->set('excel.imports.cells.middleware', []);
$worksheet = $this->read(__DIR__ . '/Data/Disks/Local/import-middleware.xlsx', 'Xlsx');
$this->assertEquals('test', Cell::make($worksheet->getActiveSheet(), 'A1')->getValue());
// By default spaces are not removed
$this->assertEquals(' ', Cell::make($worksheet->getActiveSheet(), 'A2')->getValue());
}
public function test_can_trim_empty_cells()
{
config()->set('excel.imports.cells.middleware', [
TrimCellValue::class,
]);
$worksheet = $this->read(__DIR__ . '/Data/Disks/Local/import-middleware.xlsx', 'Xlsx');
$this->assertEquals('', Cell::make($worksheet->getActiveSheet(), 'A2')->getValue());
config()->set('excel.imports.cells.middleware', []);
}
public function test_convert_empty_cells_to_null()
{
config()->set('excel.imports.cells.middleware', [
TrimCellValue::class,
ConvertEmptyCellValuesToNull::class,
]);
$worksheet = $this->read(__DIR__ . '/Data/Disks/Local/import-middleware.xlsx', 'Xlsx');
$this->assertEquals(null, Cell::make($worksheet->getActiveSheet(), 'A2')->getValue());
config()->set('excel.imports.cells.middleware', []);
}
}