Skip to content

Commit 334f79a

Browse files
committed
Move helper functions to Pest
1 parent 4194ee6 commit 334f79a

File tree

4 files changed

+26
-31
lines changed

4 files changed

+26
-31
lines changed

resources/views/pages/inventory/⚡index/index.test.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
use Illuminate\Http\UploadedFile;
88
use Livewire\Livewire;
99

10-
function amazonFixtureUpload(): UploadedFile
11-
{
12-
return UploadedFile::fake()->createWithContent(
13-
'amazon-import.csv',
14-
file_get_contents(base_path('tests/Fixtures/csv/amazon-import.csv')),
15-
);
16-
}
17-
1810
test('guests are redirected to the login page', function () {
1911
$this->get(route('inventory.index'))
2012
->assertRedirect(route('login'));

tests/Feature/Actions/Inventory/ImportItemsFromAmazonTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22

33
use App\Actions\Inventory\ImportItemsFromAmazonAction;
44
use App\Models\Team;
5-
use Illuminate\Http\UploadedFile;
6-
7-
function amazonFixture(): UploadedFile
8-
{
9-
return new UploadedFile(
10-
path: base_path('tests/Fixtures/csv/amazon-import.csv'),
11-
originalName: 'amazon-import.csv',
12-
test: true,
13-
);
14-
}
155

166
test('it imports items from amazon csv', function () {
177
$team = Team::factory()->create();

tests/Pest.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Tests\TestCase;
44
use Illuminate\Foundation\Testing\RefreshDatabase;
5+
use Illuminate\Http\UploadedFile;
56

67
/*
78
|--------------------------------------------------------------------------
@@ -44,7 +45,30 @@
4445
|
4546
*/
4647

47-
function something()
48+
function amazonFixture(): UploadedFile
4849
{
49-
// ..
50+
return new UploadedFile(
51+
path: base_path('tests/Fixtures/csv/amazon-import.csv'),
52+
originalName: 'amazon-import.csv',
53+
test: true,
54+
);
55+
}
56+
57+
function amazonFixtureUpload(): UploadedFile
58+
{
59+
return UploadedFile::fake()->createWithContent(
60+
'amazon-import.csv',
61+
file_get_contents(base_path('tests/Fixtures/csv/amazon-import.csv')),
62+
);
63+
}
64+
65+
function fakeRecipeHtml(array $schema): string
66+
{
67+
$json = json_encode($schema);
68+
69+
return <<<HTML
70+
<html><head>
71+
<script type="application/ld+json">{$json}</script>
72+
</head><body></body></html>
73+
HTML;
5074
}

tests/Unit/Actions/ImportRecipeFromUrlTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,6 @@
33
use App\Actions\Recipes\ImportRecipeFromUrl;
44
use Illuminate\Support\Facades\Http;
55

6-
function fakeRecipeHtml(array $schema): string
7-
{
8-
$json = json_encode($schema);
9-
10-
return <<<HTML
11-
<html><head>
12-
<script type="application/ld+json">{$json}</script>
13-
</head><body></body></html>
14-
HTML;
15-
}
16-
176
test('parses direct Recipe JSON-LD', function () {
187
Http::fake([
198
'example.com/*' => Http::response(fakeRecipeHtml([

0 commit comments

Comments
 (0)