Skip to content

Commit 6c74ca7

Browse files
committed
refactor: restructure test data paths, remove unnecessary testbench steps
1 parent fbaa772 commit 6c74ca7

File tree

8 files changed

+16
-26
lines changed

8 files changed

+16
-26
lines changed

testbench.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ workbench:
2323
config: true
2424
build:
2525
- asset-publish
26-
- create-sqlite-db
27-
- db-wipe
28-
- migrate-fresh
2926
- storage-link
3027
assets:
3128
- test-assets

tests/Feature/CacheTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
]));
8989

9090
$disk = Storage::disk(config()->string('image-transform-url.cache.disk'));
91-
$size = $disk->size($this->getCacheEndPath('test-data', 'cat.jpg', ['width' => 1200, 'version' => $i]));
91+
$size = $disk->size($this->getCacheEndPath('images', 'cat.jpg', ['width' => 1200, 'version' => $i]));
9292

9393
$totalSizeMB += $size / (1024 * 1024);
9494

@@ -144,7 +144,7 @@
144144
]));
145145

146146
$disk = Storage::disk(config()->string('image-transform-url.cache.disk'));
147-
$endPath = $this->getCacheEndPath('test-data', 'cat.jpg', ['width' => 1200, 'version' => $i]);
147+
$endPath = $this->getCacheEndPath('images', 'cat.jpg', ['width' => 1200, 'version' => $i]);
148148

149149
$cacheFilePaths[] = $endPath;
150150

@@ -173,7 +173,7 @@
173173
'path' => 'cat.jpg',
174174
]));
175175

176-
$lastCacheFilePath = $this->getCacheEndPath('test-data', 'cat.jpg', ['width' => 2400, 'version' => 99]);
176+
$lastCacheFilePath = $this->getCacheEndPath('images', 'cat.jpg', ['width' => 2400, 'version' => 99]);
177177

178178
$finalResponse->assertOk();
179179
$finalResponse->assertHeader('X-Cache', 'MISS');

tests/Feature/S3SourceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
it('can serve from an s3 disk source directory', function () {
2222
/** @var TestCase $this */
2323
$imagePath = 'images/test.jpg';
24-
Storage::disk('s3')->put($imagePath, file_get_contents(__DIR__.'/../../workbench/test-data/cat.jpg'));
24+
Storage::disk('s3')->put($imagePath, file_get_contents(public_path('images/cat.jpg')));
2525

2626
$response = $this->get(route('image.transform', [
2727
'options' => 'width=100',
@@ -40,7 +40,7 @@
4040
config()->set('image-transform-url.default_source_directory', 's3');
4141

4242
$imagePath = 'images/test.jpg';
43-
Storage::disk('s3')->put($imagePath, file_get_contents(__DIR__.'/../../workbench/test-data/cat.jpg'));
43+
Storage::disk('s3')->put($imagePath, file_get_contents(public_path('images/cat.jpg')));
4444

4545
$response = $this->get(route('image.transform.default', [
4646
'options' => 'width=100',

tests/Feature/SignedUrlTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ function configureTestEnvironment(): void
1616
{
1717
config()->set('image-transform-url.signed_urls.enabled', true);
1818
config()->set('image-transform-url.signed_urls.for_source_directories', ['protected']);
19-
config()->set('image-transform-url.source_directories', [
20-
'test-data' => public_path('test-data'),
21-
'protected' => Storage::fake('local')->path('protected'),
22-
]);
19+
config()->set('image-transform-url.source_directories.protected', Storage::fake('local')->path('protected'));
2320
}
2421

2522
it('can protect a route with a signed URL', function () {
2623
/** @var TestCase $this */
2724
configureTestEnvironment();
2825

29-
Storage::disk('local')->put('protected/cat.jpg', file_get_contents(public_path('test-data/cat.jpg')));
26+
Storage::disk('local')->put('protected/cat.jpg', file_get_contents(public_path('images/cat.jpg')));
3027

3128
assert(Storage::disk('local')->exists('protected/cat.jpg'));
3229

@@ -53,7 +50,7 @@ function configureTestEnvironment(): void
5350
/** @var TestCase $this */
5451
configureTestEnvironment();
5552

56-
Storage::disk('local')->put('protected/cat.jpg', file_get_contents(public_path('test-data/cat.jpg')));
53+
Storage::disk('local')->put('protected/cat.jpg', file_get_contents(public_path('images/cat.jpg')));
5754

5855
assert(Storage::disk('local')->exists('protected/cat.jpg'));
5956

@@ -80,7 +77,7 @@ function configureTestEnvironment(): void
8077
/** @var TestCase $this */
8178
configureTestEnvironment();
8279

83-
Storage::disk('local')->put('protected/cat.jpg', file_get_contents(public_path('test-data/cat.jpg')));
80+
Storage::disk('local')->put('protected/cat.jpg', file_get_contents(public_path('images/cat.jpg')));
8481

8582
assert(Storage::disk('local')->exists('protected/cat.jpg'));
8683

@@ -103,7 +100,7 @@ function configureTestEnvironment(): void
103100

104101
config()->set('image-transform-url.default_source_directory', 'protected');
105102

106-
Storage::disk('local')->put('protected/cat.jpg', file_get_contents(public_path('test-data/cat.jpg')));
103+
Storage::disk('local')->put('protected/cat.jpg', file_get_contents(public_path('images/cat.jpg')));
107104

108105
assert(Storage::disk('local')->exists('protected/cat.jpg'));
109106

tests/Feature/SourceDirectoriesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
it('can serve from the storage directory', function () {
1616

1717
$imagePath = 'images/test.jpg';
18-
Storage::disk('public')->put($imagePath, file_get_contents(__DIR__.'/../../workbench/test-data/cat.jpg'));
18+
Storage::disk('public')->put($imagePath, file_get_contents(public_path('images/cat.jpg')));
1919

2020
$response = $this->get(route('image.transform', [
2121
'options' => 'width=100',
@@ -34,7 +34,7 @@
3434
config()->set('image-transform-url.default_source_directory', 'storage');
3535

3636
$imagePath = 'images/test.jpg';
37-
Storage::disk('public')->put($imagePath, file_get_contents(__DIR__.'/../../workbench/test-data/cat.jpg'));
37+
Storage::disk('public')->put($imagePath, file_get_contents(public_path('images/cat.jpg')));
3838

3939
$response = $this->get(route('image.transform.default', [
4040
'options' => 'width=100',

tests/TestCase.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ protected function getEnvironmentSetUp($app)
4343
protected function defineEnvironment($app)
4444
{
4545
tap($app['config'], function (Repository $config) {
46-
$config->set('image-transform-url.source_directories', [
47-
'test-data' => public_path('test-data'),
48-
'storage' => Storage::fake('public')->path(''),
49-
]);
50-
$config->set('image-transform-url.default_source_directory', 'test-data');
46+
$config->set('image-transform-url.source_directories.storage', Storage::fake('public')->path(''));
5147
$config->set('image-transform-url.enabled_options', AllowedOptions::all());
5248
});
5349
}

workbench/app/Providers/WorkbenchServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function register(): void
2020
public function boot(): void
2121
{
2222
$this->publishes([
23-
__DIR__.'/../../../workbench/test-data' => public_path('test-data'),
23+
__DIR__.'/../../../workbench/test-data' => public_path('images'),
2424
], 'test-assets');
2525
}
2626
}

workbench/config/image-transform-url.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020

2121
'source_directories' => [
22-
'images-test' => public_path('images'),
22+
'images' => public_path('images'),
2323
'storage' => storage_path('app/public/images'),
2424
'remote' => ['disk' => 'r2'],
2525
],
@@ -35,7 +35,7 @@
3535
|
3636
*/
3737

38-
'default_source_directory' => env('IMAGE_TRANSFORM_DEFAULT_SOURCE_DIRECTORY', 'images-test'),
38+
'default_source_directory' => env('IMAGE_TRANSFORM_DEFAULT_SOURCE_DIRECTORY', 'images'),
3939

4040
/*
4141
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)