From a83073ac8f7d95bad24e1bae50ae6ef0115afe65 Mon Sep 17 00:00:00 2001 From: Matthew Irby Date: Mon, 13 Oct 2025 21:27:47 -0400 Subject: [PATCH 1/2] chore: move graphql-ext fixtures into separate directory Signed-off-by: Matthew Irby --- .../event-importer/tests/Feature/MeetupGraphqlExtTest.php | 6 +++--- .../event-importer/tests/Feature/MeetupGraphqlTest.php | 2 +- .../responses/accessToken/example-access-token.json | 6 ++++++ .../responses/groupByUrlName}/example-group-null.json | 0 .../responses/groupByUrlName}/example-group.json | 0 .../responses/groupByUrlName/{v1 => }/example-group.json | 0 6 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 app-modules/event-importer/tests/fixtures/meetup-graphql-ext/responses/accessToken/example-access-token.json rename app-modules/event-importer/tests/fixtures/{meetup-graphql/responses/groupByUrlName/v2 => meetup-graphql-ext/responses/groupByUrlName}/example-group-null.json (100%) rename app-modules/event-importer/tests/fixtures/{meetup-graphql/responses/groupByUrlName/v2 => meetup-graphql-ext/responses/groupByUrlName}/example-group.json (100%) rename app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/{v1 => }/example-group.json (100%) diff --git a/app-modules/event-importer/tests/Feature/MeetupGraphqlExtTest.php b/app-modules/event-importer/tests/Feature/MeetupGraphqlExtTest.php index 4bfb2d27..b5a10f36 100644 --- a/app-modules/event-importer/tests/Feature/MeetupGraphqlExtTest.php +++ b/app-modules/event-importer/tests/Feature/MeetupGraphqlExtTest.php @@ -163,7 +163,7 @@ public function test_null_group_data_is_not_imported(): void 200 ), 'https://api.meetup.com/gql-ext' => Http::response( - $this->apiResponse('responses/groupByUrlName/v2/example-group-null.json'), + $this->apiResponse('responses/groupByUrlName/example-group-null.json'), 200 ), ]); @@ -223,7 +223,7 @@ public function test_file_path_validation_fails_when_private_key_path_does_not_e protected function apiResponse(string $file): string { - return file_get_contents(__DIR__ . '/../fixtures/meetup-graphql/' . $file); + return file_get_contents(__DIR__ . '/../fixtures/meetup-graphql-ext/' . $file); } private function runImportCommand(): void @@ -258,7 +258,7 @@ private function fakeHttpCalls(): void Http::fake([ 'https://api.meetup.com/gql-ext' => Http::response( - $this->apiResponse('responses/groupByUrlName/v2/example-group.json'), // Example response from /gql-ext endpoint + $this->apiResponse('responses/groupByUrlName/example-group.json'), // Example response from /gql-ext endpoint 200 ), ]); diff --git a/app-modules/event-importer/tests/Feature/MeetupGraphqlTest.php b/app-modules/event-importer/tests/Feature/MeetupGraphqlTest.php index c3ec3779..5457f447 100644 --- a/app-modules/event-importer/tests/Feature/MeetupGraphqlTest.php +++ b/app-modules/event-importer/tests/Feature/MeetupGraphqlTest.php @@ -228,7 +228,7 @@ private function fakeHttpCalls(): void Http::fake([ 'https://api.meetup.com/gql' => Http::response( - $this->apiResponse('responses/groupByUrlName/v1/example-group.json'), // Example response from /gql-ext endpoint + $this->apiResponse('responses/groupByUrlName/example-group.json'), // Example response from /gql-ext endpoint 200 ), ]); diff --git a/app-modules/event-importer/tests/fixtures/meetup-graphql-ext/responses/accessToken/example-access-token.json b/app-modules/event-importer/tests/fixtures/meetup-graphql-ext/responses/accessToken/example-access-token.json new file mode 100644 index 00000000..76b72a72 --- /dev/null +++ b/app-modules/event-importer/tests/fixtures/meetup-graphql-ext/responses/accessToken/example-access-token.json @@ -0,0 +1,6 @@ +{ + "access_token":"fake_access_token", + "refresh_token":"fake_refresh_token", + "expires_in":3600, + "token_type":"bearer" +} diff --git a/app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/v2/example-group-null.json b/app-modules/event-importer/tests/fixtures/meetup-graphql-ext/responses/groupByUrlName/example-group-null.json similarity index 100% rename from app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/v2/example-group-null.json rename to app-modules/event-importer/tests/fixtures/meetup-graphql-ext/responses/groupByUrlName/example-group-null.json diff --git a/app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/v2/example-group.json b/app-modules/event-importer/tests/fixtures/meetup-graphql-ext/responses/groupByUrlName/example-group.json similarity index 100% rename from app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/v2/example-group.json rename to app-modules/event-importer/tests/fixtures/meetup-graphql-ext/responses/groupByUrlName/example-group.json diff --git a/app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/v1/example-group.json b/app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/example-group.json similarity index 100% rename from app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/v1/example-group.json rename to app-modules/event-importer/tests/fixtures/meetup-graphql/responses/groupByUrlName/example-group.json From 49ca665021f9c7f84b4ea16d81fea83cedcccf87 Mon Sep 17 00:00:00 2001 From: Matthew Irby Date: Mon, 13 Oct 2025 22:21:14 -0400 Subject: [PATCH 2/2] feat: Create an abstract class for event service tests Signed-off-by: Matthew Irby --- .../tests/Feature/EventBriteTest.php | 15 +++++++- .../event-importer/tests/Feature/LumaTest.php | 14 ++++++- .../tests/Feature/MeetupGraphqlExtTest.php | 22 ++++++----- .../tests/Feature/MeetupGraphqlTest.php | 17 ++++++--- .../tests/Feature/MeetupRestTest.php | 22 ++++++----- tests/AbstractEventHandlerTestCase.php | 38 +++++++++++++++++++ 6 files changed, 99 insertions(+), 29 deletions(-) create mode 100644 tests/AbstractEventHandlerTestCase.php diff --git a/app-modules/event-importer/tests/Feature/EventBriteTest.php b/app-modules/event-importer/tests/Feature/EventBriteTest.php index 4e514048..d768f5b8 100644 --- a/app-modules/event-importer/tests/Feature/EventBriteTest.php +++ b/app-modules/event-importer/tests/Feature/EventBriteTest.php @@ -7,11 +7,12 @@ use App\Models\Org; use App\Models\Venue; use HackGreenville\EventImporter\Console\Commands\ImportEventsCommand; +use HackGreenville\EventImporter\Services\EventBriteHandler; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Http; -use Tests\DatabaseTestCase; +use Tests\AbstractEventHandlerTestCase; -class EventBriteTest extends DatabaseTestCase +class EventBriteTest extends AbstractEventHandlerTestCase { protected function setUp(): void { @@ -116,4 +117,14 @@ protected function apiResponse(string $file): string { return file_get_contents(__DIR__ . '/../fixtures/eventbrite/' . $file); } + + protected function getEventService(): EventServices + { + return EventServices::EventBrite; + } + + protected function getHandlerClass(): string + { + return EventBriteHandler::class; + } } diff --git a/app-modules/event-importer/tests/Feature/LumaTest.php b/app-modules/event-importer/tests/Feature/LumaTest.php index 85a58142..aa32c353 100644 --- a/app-modules/event-importer/tests/Feature/LumaTest.php +++ b/app-modules/event-importer/tests/Feature/LumaTest.php @@ -10,9 +10,9 @@ use HackGreenville\EventImporter\Services\LumaHandler; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Http; -use Tests\DatabaseTestCase; +use Tests\AbstractEventHandlerTestCase; -class LumaTest extends DatabaseTestCase +class LumaTest extends AbstractEventHandlerTestCase { protected function setUp(): void { @@ -126,4 +126,14 @@ protected function apiResponse(string $file): string { return file_get_contents(__DIR__ . '/../fixtures/luma/' . $file); } + + protected function getEventService(): EventServices + { + return EventServices::Luma; + } + + protected function getHandlerClass(): string + { + return LumaHandler::class; + } } diff --git a/app-modules/event-importer/tests/Feature/MeetupGraphqlExtTest.php b/app-modules/event-importer/tests/Feature/MeetupGraphqlExtTest.php index b5a10f36..b5398aa0 100644 --- a/app-modules/event-importer/tests/Feature/MeetupGraphqlExtTest.php +++ b/app-modules/event-importer/tests/Feature/MeetupGraphqlExtTest.php @@ -9,9 +9,9 @@ use HackGreenville\EventImporter\Services\MeetupGraphqlExtHandler; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Http; -use Tests\DatabaseTestCase; +use Tests\AbstractEventHandlerTestCase; -class MeetupGraphqlExtTest extends DatabaseTestCase +class MeetupGraphqlExtTest extends AbstractEventHandlerTestCase { protected function setUp(): void { @@ -27,14 +27,6 @@ protected function setUp(): void config()->set('event-import-handlers.meetup_graphql_member_id', 'bar'); config()->set('event-import-handlers.meetup_graphql_private_key_id', 'abc123'); - config()->set('event-import-handlers.handlers', [ - EventServices::MeetupGraphql->value => MeetupGraphqlExtHandler::class, - ]); - - config()->set('event-import-handlers.active_services', [ - EventServices::MeetupGraphql->value, - ]); - Org::factory()->create([ 'service' => EventServices::MeetupGraphql, 'service_api_key' => 'defcon864', @@ -226,6 +218,16 @@ protected function apiResponse(string $file): string return file_get_contents(__DIR__ . '/../fixtures/meetup-graphql-ext/' . $file); } + protected function getEventService(): EventServices + { + return EventServices::MeetupGraphql; + } + + protected function getHandlerClass(): string + { + return MeetupGraphqlExtHandler::class; + } + private function runImportCommand(): void { $this->artisan(ImportEventsCommand::class); diff --git a/app-modules/event-importer/tests/Feature/MeetupGraphqlTest.php b/app-modules/event-importer/tests/Feature/MeetupGraphqlTest.php index 5457f447..33f5df34 100644 --- a/app-modules/event-importer/tests/Feature/MeetupGraphqlTest.php +++ b/app-modules/event-importer/tests/Feature/MeetupGraphqlTest.php @@ -9,9 +9,9 @@ use HackGreenville\EventImporter\Services\MeetupGraphqlHandler; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Http; -use Tests\DatabaseTestCase; +use Tests\AbstractEventHandlerTestCase; -class MeetupGraphqlTest extends DatabaseTestCase +class MeetupGraphqlTest extends AbstractEventHandlerTestCase { protected function setUp(): void { @@ -25,9 +25,6 @@ protected function setUp(): void config()->set('event-import-handlers.meetup_graphql_client_id', 'foo'); config()->set('event-import-handlers.meetup_graphql_member_id', 'bar'); config()->set('event-import-handlers.meetup_graphql_private_key_id', 'abc123'); - config()->set('event-import-handlers.handlers', [ - EventServices::MeetupGraphql->value => MeetupGraphqlHandler::class, - ]); Org::factory()->create([ 'service' => EventServices::MeetupGraphql, @@ -196,6 +193,16 @@ protected function apiResponse(string $file): string return file_get_contents(__DIR__ . '/../fixtures/meetup-graphql/' . $file); } + protected function getEventService(): EventServices + { + return EventServices::MeetupGraphql; + } + + protected function getHandlerClass(): string + { + return MeetupGraphqlHandler::class; + } + private function runImportCommand(): void { $this->artisan(ImportEventsCommand::class); diff --git a/app-modules/event-importer/tests/Feature/MeetupRestTest.php b/app-modules/event-importer/tests/Feature/MeetupRestTest.php index 4886ca52..ad2a9dcd 100644 --- a/app-modules/event-importer/tests/Feature/MeetupRestTest.php +++ b/app-modules/event-importer/tests/Feature/MeetupRestTest.php @@ -9,21 +9,13 @@ use HackGreenville\EventImporter\Services\MeetupRestHandler; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Http; -use Tests\DatabaseTestCase; +use Tests\AbstractEventHandlerTestCase; -class MeetupRestTest extends DatabaseTestCase +class MeetupRestTest extends AbstractEventHandlerTestCase { protected function setUp(): void { parent::setUp(); - - config()->set('event-import-handlers.handlers', [ - EventServices::MeetupRest->value => MeetupRestHandler::class, - ]); - - config()->set('event-import-handlers.active_services', [ - EventServices::MeetupRest->value - ]); } public function test_active_meetup_event_is_imported_correctly(): void @@ -96,4 +88,14 @@ protected function apiResponse(string $file): string { return file_get_contents(__DIR__ . '/../fixtures/meetup-rest/' . $file); } + + protected function getEventService(): EventServices + { + return EventServices::MeetupRest; + } + + protected function getHandlerClass(): string + { + return MeetupRestHandler::class; + } } diff --git a/tests/AbstractEventHandlerTestCase.php b/tests/AbstractEventHandlerTestCase.php new file mode 100644 index 00000000..694453e9 --- /dev/null +++ b/tests/AbstractEventHandlerTestCase.php @@ -0,0 +1,38 @@ +getEventService(); + $handlerClass = $this->getHandlerClass(); + + // Set the handler mapping + config([ + 'event-import-handlers.handlers.' . $eventService->value => $handlerClass, + ]); + + // Set the active service if not already set + $activeServices = config('event-import-handlers.active_services', []); + if ( ! in_array($eventService->value, $activeServices)) { + $activeServices[] = $eventService->value; + config(['event-import-handlers.active_services' => $activeServices]); + } + } + + /** + * Get the event service enum for this test class + */ + abstract protected function getEventService(): EventServices; + + /** + * Get the handler class for this test + */ + abstract protected function getHandlerClass(): string; +}