Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daveearley committed Jul 11, 2024
1 parent 10b1bdb commit 13b06f9
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use HiEvents\Repository\Interfaces\EventStatisticRepositoryInterface;
use HiEvents\Repository\Interfaces\OrganizerRepositoryInterface;
use HiEvents\Services\Domain\Event\CreateEventService;
use HTMLPurifier;
use Illuminate\Database\DatabaseManager;
use Mockery;
use Tests\TestCase;
Expand All @@ -24,6 +25,7 @@ class CreateEventServiceTest extends TestCase
private OrganizerRepositoryInterface $organizerRepository;
private DatabaseManager $databaseManager;
private EventStatisticRepositoryInterface $eventStatisticsRepository;
private HTMLPurifier $purifier;

protected function setUp(): void
{
Expand All @@ -34,13 +36,15 @@ protected function setUp(): void
$this->organizerRepository = Mockery::mock(OrganizerRepositoryInterface::class);
$this->databaseManager = Mockery::mock(DatabaseManager::class);
$this->eventStatisticsRepository = Mockery::mock(EventStatisticRepositoryInterface::class);
$this->purifier = Mockery::mock(HTMLPurifier::class);

$this->createEventService = new CreateEventService(
$this->eventRepository,
$this->eventSettingsRepository,
$this->organizerRepository,
$this->databaseManager,
$this->eventStatisticsRepository
$this->eventStatisticsRepository,
$this->purifier,
);
}

Expand Down Expand Up @@ -86,6 +90,9 @@ public function testCreateEventSuccess(): void
$arg['sales_total_gross'] === 0;
}));


$this->purifier->shouldReceive('purify')->andReturn('Test Description');

$result = $this->createEventService->createEvent($eventData, $eventSettings);

$this->assertInstanceOf(EventDomainObject::class, $result);
Expand All @@ -103,6 +110,8 @@ public function testCreateEventWithoutEventSettings(): void
$this->organizerRepository->shouldReceive('findFirstWhere')->andReturn($organizer);
$this->eventRepository->shouldReceive('create')->andReturn($eventData);

$this->purifier->shouldReceive('purify')->andReturn('Test Description');

$this->eventSettingsRepository->shouldReceive('create')
->with(Mockery::on(function ($arg) use ($eventData, $organizer) {
return $arg['event_id'] === $eventData->getId() &&
Expand Down

0 comments on commit 13b06f9

Please sign in to comment.