Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.3, 8.4, 8.5]
php: [8.4, 8.5]
env:
DB_CONNECTION: sqlite
DB_DATABASE: testing.sqlite
Expand Down Expand Up @@ -84,13 +84,18 @@ jobs:
env:
CREATE_SNAPSHOTS: "false"

- name: Feature tests
run: vendor/bin/pest tests/Feature --parallel --do-not-fail-on-phpunit-warning
env:
CREATE_SNAPSHOTS: "false"

mysql:
name: MySQL
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.5]
php: [8.4, 8.5]
database: ["mysql:8.4", "mysql:9.6"]
services:
database:
Expand Down Expand Up @@ -153,7 +158,7 @@ jobs:
fail-fast: true
matrix:
php: [8.5]
database: ["mariadb:10.11", "mariadb:11.4"]
database: ["mariadb:11.4"]
services:
database:
image: ${{ matrix.database }}
Expand Down
3 changes: 2 additions & 1 deletion app/Listeners/DispatchWebhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ protected function handleGenericClassEvent(string $eventName, array $payload): v
$obj = $payload[0] ?? null;
$webhookData = ['event' => $eventName, 'timestamp' => now()->toIso8601String()];
if (is_object($obj)) {
$webhookData['data'] = $obj->toArray();
// Custom event classes rarely implement toArray, so fall back to their public properties
$webhookData['data'] = method_exists($obj, 'toArray') ? $obj->toArray() : get_object_vars($obj);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
} elseif (is_array($obj)) {
$webhookData['data'] = $obj;
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "The free, open-source game management panel. Supporting Minecraft, Spigot, BungeeCord, and SRCDS servers.",
"license": "AGPL-3.0-only",
"require": {
"php": "^8.3 || ^8.4 || ^8.5",
"php": "^8.4 || ^8.5",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
Expand Down Expand Up @@ -94,7 +94,7 @@
"pestphp/pest-plugin": true
},
"platform": {
"php": "8.3"
"php": "8.4"
}
},
"minimum-stability": "stable",
Expand Down
6 changes: 3 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<testsuite name="Filament">
<directory>./tests/Filament</directory>
</testsuite>
<testsuite name="Feature">
<directory>./tests/Feature</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Webhooks/DispatchWebhooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function test_it_does_not_call_removed_events(): void
'events' => ['eloquent.created: '.Server::class],
]);

$webhookConfig->update(['events' => 'eloquent.deleted: '.Server::class]);
$webhookConfig->update(['events' => ['eloquent.deleted: '.Server::class]]);

$this->createServer();

Expand Down
13 changes: 8 additions & 5 deletions tests/Feature/Webhooks/ProcessWebhooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ public function test_it_sends_a_single_webhook(): void
ProcessWebhook::dispatchSync(
$webhook,
'eloquent.created: '.Server::class,
$data,
[$data],
);

$this->assertCount(1, cache()->get("webhooks.$eventName"));
$this->assertEquals($webhook->id, cache()->get("webhooks.$eventName")->first()->id);

$expected = $data;
$expected['event'] = WebhookConfiguration::transformClassName($eventName);

Http::assertSentCount(1);
Http::assertSent(function (Request $request) use ($webhook, $data) {
Http::assertSent(function (Request $request) use ($webhook, $expected) {
return $webhook->endpoint === $request->url()
&& $request->data() === $data;
&& $request->data() === $expected;
});
}

Expand Down Expand Up @@ -143,7 +146,7 @@ public function test_it_records_when_a_webhook_is_sent(): void
$this->assertDatabaseCount(Webhook::class, 1);

$webhook = Webhook::query()->first();
$this->assertEquals($server->uuid, $webhook->payload[0]['uuid']);
$this->assertEquals($server->uuid, $webhook->payload['data']['uuid']);

$this->assertDatabaseHas(Webhook::class, [
'endpoint' => $webhookConfig->endpoint,
Expand All @@ -165,8 +168,8 @@ public function test_it_records_when_a_webhook_fails(): void
$server = $this->createServer();

$this->assertDatabaseCount(Webhook::class, 1);
$this->assertEquals($server->uuid, Webhook::query()->first()->payload['data']['uuid']);
$this->assertDatabaseHas(Webhook::class, [
'payload' => json_encode([$server->toArray()]),
'endpoint' => $webhookConfig->endpoint,
'successful_at' => null,
'event' => 'eloquent.created: '.Server::class,
Expand Down
Loading