Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace Tests\Unit\Services\Application\Handlers\Images;
use HiEvents\DomainObjects\Enums\ImageType;
use HiEvents\DomainObjects\ImageDomainObject;
use HiEvents\DomainObjects\UserDomainObject;
use HiEvents\Repository\Interfaces\EventRepositoryInterface;
use HiEvents\Repository\Interfaces\ImageRepositoryInterface;
use HiEvents\Repository\Interfaces\OrganizerRepositoryInterface;
use HiEvents\Repository\Interfaces\ProfileRepositoryInterface;
use HiEvents\Services\Application\Handlers\Images\CreateImageHandler;
use HiEvents\Services\Application\Handlers\Images\DTO\CreateImageDTO;
use HiEvents\Services\Domain\Image\ImageUploadService;
use Illuminate\Http\UploadedFile;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class CreateImageHandlerTest extends TestCase
{
private ImageUploadService $imageUploadService;
private CreateImageHandler $handler;
protected function setUp(): void
{
parent::setUp();
$this->imageUploadService = m::mock(ImageUploadService::class);
$organizerRepository = m::mock(OrganizerRepositoryInterface::class);
$eventRepository = m::mock(EventRepositoryInterface::class);
$imageRepository = m::mock(ImageRepositoryInterface::class);
$this->handler = new CreateImageHandler(
$this->imageUploadService,
$organizerRepository,
$eventRepository,
$imageRepository,
m::mock(ProfileRepositoryInterface::class),
);
}
public function test_handle_successfully_creates_image(): void
{
$uploadedFile = m::mock(UploadedFile::class);
$imageDomainObject = m::mock(ImageDomainObject::class);
$accountId = 123;
$dto = new CreateImageDTO(
userId: 42,
accountId: $accountId,
image: $uploadedFile
);
$this->imageUploadService
->shouldReceive('upload')
->once()
->withArgs([
$uploadedFile,
42,
UserDomainObject::class,
ImageType::GENERIC->name,
$accountId,
])
->andReturn($imageDomainObject);
$result = $this->handler->handle($dto);
$this->assertSame($imageDomainObject, $result);
}
protected function tearDown(): void
{
m::close();
parent::tearDown();
}
}