Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 19 additions & 6 deletions .github/workflows/unit-tests.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
name: Run Unit Tests
name: Backend Tests

on:
push:
branches: [main, develop]
paths:
- 'backend/**'
- '.github/workflows/unit-tests.yml'
- '.github/workflows/tests.yml'
pull_request:
paths:
- 'backend/**'
- '.github/workflows/unit-tests.yml'
- '.github/workflows/tests.yml'

jobs:
run-tests:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: ['8.2', '8.3', '8.4']

services:
# Postgres is started for the Feature suite. The Unit suite does not need
# a live connection — it only reads DB_DATABASE for the _test guard check
# in CreatesApplication — so it runs in parallel with Postgres warming up.
postgres:
image: postgres:15
env:
Expand Down Expand Up @@ -80,6 +83,13 @@ jobs:
# to .env so both paths see the same config.
run: cp backend/.env.testing backend/.env

- name: Run Unit test suite
# Pure unit tests — no DB connection, no migrations. The CreatesApplication
# bootstrap detects the absence of DatabaseTransactions / RefreshDatabase
# traits and skips migrate:fresh entirely. Runs in parallel with the
# Postgres service container coming up.
run: cd backend && ./vendor/bin/phpunit --testsuite=Unit --no-coverage

- name: Wait for Postgres
run: |
for i in {1..30}; do
Expand All @@ -91,5 +101,8 @@ jobs:
echo "Postgres did not become ready in time" >&2
exit 1

- name: Run PHPUnit Tests
run: cd backend && ./vendor/bin/phpunit tests/Unit --no-coverage
- name: Run Feature test suite
# Integration tests against the real PostgreSQL test database. The first
# test that boots Laravel triggers migrate:fresh once per process via
# CreatesApplication::ensureTestDatabaseIsMigrated.
run: cd backend && ./vendor/bin/phpunit --testsuite=Feature --no-coverage
14 changes: 14 additions & 0 deletions backend/app/DomainObjects/AttendeeDomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class AttendeeDomainObject extends Generated\AttendeeDomainObjectAbstract implem
/** @var Collection<AttendeeCheckInDomainObject>|null */
private ?Collection $checkIns = null;

private ?EventOccurrenceDomainObject $eventOccurrence = null;

public static function getDefaultSort(): string
{
return self::CREATED_AT;
Expand Down Expand Up @@ -71,6 +73,7 @@ public static function getAllowedFilterFields(): array
self::STATUS,
self::PRODUCT_ID,
self::PRODUCT_PRICE_ID,
self::EVENT_OCCURRENCE_ID,
];
}

Expand Down Expand Up @@ -138,4 +141,15 @@ public function getCheckIns(): ?Collection
{
return $this->checkIns;
}

public function setEventOccurrence(?EventOccurrenceDomainObject $eventOccurrence): AttendeeDomainObject
{
$this->eventOccurrence = $eventOccurrence;
return $this;
}

public function getEventOccurrence(): ?EventOccurrenceDomainObject
{
return $this->eventOccurrence;
}
}
14 changes: 14 additions & 0 deletions backend/app/DomainObjects/CheckInListDomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class CheckInListDomainObject extends Generated\CheckInListDomainObjectAbstract

private ?EventDomainObject $event = null;

private ?EventOccurrenceDomainObject $eventOccurrence = null;

private ?int $checkedInCount = null;

private ?int $totalAttendeesCount = null;
Expand Down Expand Up @@ -77,6 +79,18 @@ public function setEvent(?EventDomainObject $event): static
return $this;
}

public function getEventOccurrence(): ?EventOccurrenceDomainObject
{
return $this->eventOccurrence;
}

public function setEventOccurrence(?EventOccurrenceDomainObject $eventOccurrence): static
{
$this->eventOccurrence = $eventOccurrence;

return $this;
}

public function isExpired(string $timezone): bool
{
if ($this->getExpiresAt() === null) {
Expand Down
12 changes: 12 additions & 0 deletions backend/app/DomainObjects/Enums/BulkOccurrenceAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace HiEvents\DomainObjects\Enums;

enum BulkOccurrenceAction: string
{
use BaseEnum;

case UPDATE = 'update';
case CANCEL = 'cancel';
case DELETE = 'delete';
}
12 changes: 12 additions & 0 deletions backend/app/DomainObjects/Enums/EmailTemplateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ enum EmailTemplateType: string

case ORDER_CONFIRMATION = 'order_confirmation';
case ATTENDEE_TICKET = 'attendee_ticket';
case OCCURRENCE_CANCELLATION = 'occurrence_cancellation';

public function label(): string
{
return match ($this) {
self::ORDER_CONFIRMATION => __('Order Confirmation'),
self::ATTENDEE_TICKET => __('Attendee Ticket'),
self::OCCURRENCE_CANCELLATION => __('Date Cancellation'),
};
}

Expand All @@ -22,6 +24,16 @@ public function description(): string
return match ($this) {
self::ORDER_CONFIRMATION => __('Sent to the customer after placing an order'),
self::ATTENDEE_TICKET => __('Sent to each attendee with their ticket'),
self::OCCURRENCE_CANCELLATION => __('Sent to attendees when a scheduled date is cancelled'),
};
}

public function ctaUrlToken(): string
{
return match ($this) {
self::ORDER_CONFIRMATION => 'order.url',
self::ATTENDEE_TICKET => 'ticket.url',
self::OCCURRENCE_CANCELLATION => 'event.url',
};
}
}
11 changes: 11 additions & 0 deletions backend/app/DomainObjects/Enums/EventType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace HiEvents\DomainObjects\Enums;

enum EventType
{
use BaseEnum;

case SINGLE;
case RECURRING;
}
1 change: 1 addition & 0 deletions backend/app/DomainObjects/Enums/ReportTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ enum ReportTypes: string
case PRODUCT_SALES = 'product_sales';
case DAILY_SALES_REPORT = 'daily_sales_report';
case PROMO_CODES_REPORT = 'promo_codes_report';
case OCCURRENCE_SUMMARY = 'occurrence_summary';
}
Loading
Loading