Skip to content

Commit 112601b

Browse files
committed
wip
1 parent 46b4c6c commit 112601b

File tree

3 files changed

+18
-920
lines changed

3 files changed

+18
-920
lines changed

tests/ChunkIteratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
$result = collect($chunks);
2525

2626
$this->assertEquals(count((array) $result->first()), 10);
27-
$this->assertEquals($result->keys()->count(), 100);
27+
$this->assertEquals($result->keys()->count(), 10);
2828
});

tests/CsvImporterTest.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,23 @@
2323
});
2424

2525
it('renders import CSV component with model and file', function () {
26-
Storage::fake();
27-
28-
$path = __DIR__.DIRECTORY_SEPARATOR.'stubs'.DIRECTORY_SEPARATOR.'customers.csv';
2926
$model = Customer::class;
3027

3128
$file = UploadedFile::fake()
32-
->create('customers.csv', 10, 'csv');
29+
->createWithContent(
30+
'customers.csv',
31+
file_get_contents('stubs/customers.csv', true)
32+
);
3333

3434
livewire(CsvImporter::class, [
3535
'model' => $model,
3636
])
37-
->set('file', $path)
37+
->set('file', $file)
3838
->assertSet('model', $model)
3939
->assertSuccessful();
4040
});
4141

4242
it('throws a validation error if the csv file empty', function () {
43-
Storage::fake();
4443
$model = Customer::class;
4544

4645
$file = UploadedFile::fake()
@@ -52,15 +51,14 @@
5251
livewire(CsvImporter::class, [
5352
'model' => $model,
5453
])
55-
->set('file', $file)
56-
->assertSet('model', $model)
57-
->assertHasErrors(['file']);
54+
->set('file', $file)
55+
->assertSet('model', $model)
56+
->assertHasErrors(['file']);
5857
});
5958

6059
it('throws a validation error if the csv file has duplicate headers', function () {
61-
Storage::fake();
62-
6360
$model = Customer::class;
61+
6462
$file = UploadedFile::fake()
6563
->createWithContent(
6664
'customers.csv',
@@ -70,9 +68,9 @@
7068
livewire(CsvImporter::class, [
7169
'model' => $model,
7270
])
73-
->set('file', $file)
74-
->assertSet('model', $model)
75-
->assertHasErrors(['file']);
71+
->set('file', $file)
72+
->assertSet('model', $model)
73+
->assertHasErrors(['file']);
7674
});
7775

7876
it('transfers columnsToMap into an associative array', function () {
@@ -171,7 +169,7 @@
171169
->assertSet('fileHeaders', [
172170
'id', 'first_name', 'last_name', 'email', 'company', 'vip', 'birthday', 'created_at', 'updated_at',
173171
])
174-
->assertSet('fileRowCount', 1000);
172+
->assertSet('fileRowCount', 100);
175173
});
176174

177175
it('throws validation errors, if the file extension does not match', function () {
@@ -250,7 +248,7 @@
250248

251249
Bus::assertBatched(function (PendingBatch $batch) {
252250
return $batch->name == 'import-csv' &&
253-
$batch->jobs->count() === 100;
251+
$batch->jobs->count() === 10;
254252
});
255253

256254
$this->assertEquals(Import::count(), 1);
@@ -284,8 +282,8 @@
284282

285283
$this->assertEquals(Import::count(), 1);
286284
$this->assertEquals($import->count(), 1);
287-
$this->assertEquals(Customer::count(), 1000);
288-
$this->assertEquals($import->first()->processed_rows, 1000);
285+
$this->assertEquals(Customer::count(), 100);
286+
$this->assertEquals($import->first()->processed_rows, 100);
289287
});
290288

291289
it('toggles import button', function () {

0 commit comments

Comments
 (0)