reupload
This commit is contained in:
104
tests/Feature/Api/V1/MediaTest.php
Normal file
104
tests/Feature/Api/V1/MediaTest.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
use App\Models\CMS\Media\Banner;
|
||||
use App\Models\CMS\Media\Carousel;
|
||||
|
||||
test('banners can be retrieved', function () {
|
||||
Banner::create([
|
||||
'title' => ['en' => 'Test Banner'],
|
||||
'description' => ['en' => 'Test Description'],
|
||||
'place' => 'market',
|
||||
'is_visible' => true,
|
||||
'sort_order' => 1,
|
||||
]);
|
||||
|
||||
Banner::create([
|
||||
'title' => ['en' => 'Hidden Banner'],
|
||||
'place' => 'market',
|
||||
'is_visible' => false,
|
||||
'sort_order' => 2,
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders(['Api-Token' => config('ecommerce.api.token')])
|
||||
->getJson('/api/v1/media/banners');
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonStructure([
|
||||
'data',
|
||||
'pagination',
|
||||
]);
|
||||
|
||||
$this->assertCount(1, $response->json('data'));
|
||||
$this->assertEquals('Test Banner', $response->json('data.0.title'));
|
||||
});
|
||||
|
||||
test('banners can be filtered by place', function () {
|
||||
Banner::create([
|
||||
'title' => ['en' => 'Place Banner'],
|
||||
'place' => 'market',
|
||||
'is_visible' => true,
|
||||
]);
|
||||
|
||||
Banner::create([
|
||||
'title' => ['en' => 'Other Banner'],
|
||||
'place' => 'store',
|
||||
'is_visible' => true,
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders(['Api-Token' => config('ecommerce.api.token')])
|
||||
->getJson('/api/v1/media/banners?place=market');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertCount(1, $response->json('data'));
|
||||
$this->assertEquals('Place Banner', $response->json('data.0.title'));
|
||||
});
|
||||
|
||||
test('carousels can be retrieved', function () {
|
||||
Carousel::create([
|
||||
'title' => ['en' => 'Test Carousel'],
|
||||
'description' => ['en' => 'Test Description'],
|
||||
'place' => 'homepage',
|
||||
'is_visible' => true,
|
||||
'sort_order' => 1,
|
||||
]);
|
||||
|
||||
Carousel::create([
|
||||
'title' => ['en' => 'Hidden Carousel'],
|
||||
'place' => 'homepage',
|
||||
'is_visible' => false,
|
||||
'sort_order' => 2,
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders(['Api-Token' => config('ecommerce.api.token')])
|
||||
->getJson('/api/v1/media/carousels');
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonStructure([
|
||||
'data',
|
||||
'pagination',
|
||||
]);
|
||||
|
||||
$this->assertCount(1, $response->json('data'));
|
||||
$this->assertEquals('Test Carousel', $response->json('data.0.title'));
|
||||
});
|
||||
|
||||
test('carousels can be filtered by place', function () {
|
||||
Carousel::create([
|
||||
'title' => ['en' => 'Place Carousel'],
|
||||
'place' => 'homepage',
|
||||
'is_visible' => true,
|
||||
]);
|
||||
|
||||
Carousel::create([
|
||||
'title' => ['en' => 'Other Carousel'],
|
||||
'place' => 'other',
|
||||
'is_visible' => true,
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders(['Api-Token' => config('ecommerce.api.token')])
|
||||
->getJson('/api/v1/media/carousels?place=homepage');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertCount(1, $response->json('data'));
|
||||
$this->assertEquals('Place Carousel', $response->json('data.0.title'));
|
||||
});
|
||||
Reference in New Issue
Block a user