Skip to content
This repository was archived by the owner on Feb 18, 2023. It is now read-only.

Commit 0756fa4

Browse files
author
joselfonseca
committed
render image and placeholder
1 parent c41c464 commit 0756fa4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Tests\Feature\Assets;
4+
5+
use App\Entities\User;
6+
use Illuminate\Foundation\Testing\RefreshDatabase;
7+
use Illuminate\Support\Str;
8+
use Laravel\Passport\Passport;
9+
use Tests\TestCase;
10+
11+
class RenderFileTest extends TestCase
12+
{
13+
use RefreshDatabase;
14+
15+
function test_it_renders_image()
16+
{
17+
$file = base64_encode(file_get_contents(base_path('tests/Resources/pic.png')));
18+
Passport::actingAs(factory(User::class)->create());
19+
$server = $this->transformHeadersToServerVars([
20+
'Content-Type' => 'image/png',
21+
'Content-Length' => mb_strlen($file)
22+
]);
23+
$response = $this->call('POST', 'api/assets', [], [], [], $server, $file);
24+
$asset = json_decode($response->getContent());
25+
$response = $this->get('api/assets/'.$asset->data->id.'/render');
26+
$response->assertStatus(200);
27+
$headers = $response->headers;
28+
$this->assertTrue($headers->has('Content-Type'));
29+
$this->assertEquals('image/png', $headers->get('Content-Type'));
30+
}
31+
32+
function test_it_renders_placeholder_image()
33+
{
34+
Passport::actingAs(factory(User::class)->create());
35+
$response = $this->get('api/assets/'.Str::uuid().'/render');
36+
$response->assertStatus(200);
37+
$headers = $response->headers;
38+
$this->assertTrue($headers->has('Content-Type'));
39+
$this->assertEquals('image/jpeg', $headers->get('Content-Type'));
40+
}
41+
}

0 commit comments

Comments
 (0)