10.April 2026
This commit is contained in:
parent
4a8f4b4abc
commit
396d049439
203 changed files with 18098 additions and 2911 deletions
90
tests/Feature/Incentive/IncentiveTeaserPageTest.php
Normal file
90
tests/Feature/Incentive/IncentiveTeaserPageTest.php
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\User\IncentiveController;
|
||||
use App\Models\Incentive;
|
||||
use App\Models\IncentiveParticipant;
|
||||
use App\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
it('collectGalleryImages returns an array of image paths excluding the hero image', function () {
|
||||
$incentive = Incentive::factory()->active()->create([
|
||||
'image' => 'nikki-beach.jpg',
|
||||
]);
|
||||
|
||||
$controller = new IncentiveController;
|
||||
|
||||
$method = new ReflectionMethod($controller, 'collectGalleryImages');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($controller, $incentive);
|
||||
|
||||
expect($result)->toBeArray();
|
||||
expect($result)->not->toContain('img/incentive/nikki-beach.jpg');
|
||||
|
||||
foreach ($result as $path) {
|
||||
expect($path)->toStartWith('img/incentive/');
|
||||
}
|
||||
});
|
||||
|
||||
it('collectGalleryImages returns empty array when directory does not exist', function () {
|
||||
$incentive = Incentive::factory()->active()->create([
|
||||
'image' => 'nonexistent-hero.jpg',
|
||||
]);
|
||||
|
||||
$controller = new IncentiveController;
|
||||
|
||||
$method = new ReflectionMethod($controller, 'collectGalleryImages');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($controller, $incentive);
|
||||
|
||||
expect($result)->toBeArray();
|
||||
});
|
||||
|
||||
it('collectGalleryImages returns sorted results', function () {
|
||||
$incentive = Incentive::factory()->active()->create([
|
||||
'image' => 'nikki-beach.jpg',
|
||||
]);
|
||||
|
||||
$controller = new IncentiveController;
|
||||
|
||||
$method = new ReflectionMethod($controller, 'collectGalleryImages');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($controller, $incentive);
|
||||
|
||||
$sorted = $result;
|
||||
sort($sorted);
|
||||
|
||||
expect($result)->toBe($sorted);
|
||||
});
|
||||
|
||||
it('teaser view receives galleryImages and participant data', function () {
|
||||
$incentive = Incentive::factory()->active()->create();
|
||||
|
||||
$user = User::forceCreate([
|
||||
'email' => 'teaser-' . uniqid('', true) . '@example.com',
|
||||
'password' => bcrypt('secret'),
|
||||
'lang' => 'de',
|
||||
'active' => 1,
|
||||
]);
|
||||
|
||||
$participant = IncentiveParticipant::factory()->create([
|
||||
'incentive_id' => $incentive->id,
|
||||
'user_id' => $user->id,
|
||||
'accepted_terms_at' => now(),
|
||||
]);
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$controller = new IncentiveController;
|
||||
$response = $controller->teaser($incentive->slug);
|
||||
|
||||
$data = $response->getData();
|
||||
expect($data)->toHaveKeys(['incentive', 'participant', 'galleryImages'])
|
||||
->and($data['incentive']->id)->toBe($incentive->id)
|
||||
->and($data['participant']->id)->toBe($participant->id)
|
||||
->and($data['galleryImages'])->toBeArray();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue