Skip to content

Commit

Permalink
chore: add test for data validity
Browse files Browse the repository at this point in the history
  • Loading branch information
k0d3r1s committed Mar 18, 2024
1 parent 0de1285 commit 027268d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Binary file added tests/assets/mock.xlsx
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/src/XLSXParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ public function testOpen(): void
$this->assertEquals(expected: new DateTimeImmutable(datetime: '2022-12-05'), actual: $values[2][5]);
}

public function testDataValidity(): void
{
$workbook = (new XLSXParser())->open(path: dirname(path: __DIR__) . '/assets/mock.xlsx');
$this->assertEquals(expected: ['data', ], actual: $workbook->getWorksheets());
$values = [];
foreach ($workbook->getRows(index: $workbook->getIndex(name: 'data')) as $key => $row) {
$values[$key] = $row;
}

$this->assertCount(expectedCount: 1001, haystack: $values);
$data = [
'JM1NC2MF8E0960570', 'Acura', 'TSX', 2012, 'Teal', 218514, 'Electric', 'Manual', 5.6, 272, 159, 1,
73103.86, '5/10/2022', 'Augusto Grissett', 27, 'Male', '85426 International Trail', 'Néa Karyá',
'Greece', '4/24/2018', '', 'XYZ789', 'Topicblab', 469689, '3/7/2029', 'Maecenas ut massa quis augue luctus tincidunt. Nulla mollis molestie lorem. Quisque ut erat.
Curabitur gravida nisi at nibh. In hac habitasse platea dictumst. Aliquam augue quam, sollicitudin vitae, consectetuer eget, rutrum at, lorem.
Integer tincidunt ante vel ipsum. Praesent blandit lacinia erat. Vestibulum sed magna at nunc commodo placerat.', true, 'Curabitur at ipsum ac tellus semper interdum. Mauris ullamcorper purus sit amet nulla. Quisque arcu libero, rutrum ac, lobortis vel, dapibus at, diam.', false,
];
$this->assertEquals(expected: $data, actual: $values[2]);
}

public function testOpenCellXfs(): void
{
$workbook = (new XLSXParser())->open(path: dirname(path: __DIR__) . '/assets/samplefile.xlsx');
Expand Down

0 comments on commit 027268d

Please sign in to comment.