Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com>
  • Loading branch information
sampoyigi committed Jan 20, 2024
1 parent 855fc60 commit 94a0963
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 87 deletions.
128 changes: 67 additions & 61 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,70 @@
{
"name": "igniterlabs/ti-ext-webhook",
"type": "tastyigniter-package",
"description": "Connect your third party apps via Zapier or other third-party services to your TastyIgniter website.",
"license": "MIT",
"authors": [
{
"name": "Igniter Labs Team",
"email": "hello@igniterlabs.co.uk"
}
],
"require-dev": {
"laravel/pint": "^1.2",
"nunomaduro/larastan": "^2.4.0",
"orchestra/testbench": "^8.5",
"pestphp/pest-plugin-laravel": "^2.0",
"tastyigniter/core": "dev-master",
"tastyigniter/ti-ext-api": "v4.x-dev as 4.0",
"tastyigniter/ti-ext-automation": "v4.x-dev as 4.0"
"name": "igniterlabs/ti-ext-webhook",
"type": "tastyigniter-package",
"description": "Connect your third party apps via Zapier or other third-party services to your TastyIgniter website.",
"license": "MIT",
"authors": [
{
"name": "Igniter Labs Team",
"email": "hello@igniterlabs.co.uk"
}
],
"repositories": [
{
"type": "path",
"url": "../../../core/"
}
],
"require-dev": {
"laravel/pint": "^1.2",
"nunomaduro/larastan": "^2.4.0",
"sampoyigi/testbench": "dev-main as 1.0",
"pestphp/pest-plugin-laravel": "^2.0",
"tastyigniter/core": "*@dev",
"tastyigniter/ti-ext-api": "v4.x-dev as 4.0",
"tastyigniter/ti-ext-automation": "v4.x-dev as 4.0"
},
"autoload": {
"psr-4": {
"IgniterLabs\\Webhook\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"IgniterLabs\\Webhook\\Tests\\": "tests/"
}
},
"extra": {
"tastyigniter-extension": {
"code": "igniterlabs.webhook",
"name": "Webhooks",
"icon": {
"image": "icon.svg",
"backgroundColor": "#147EFB",
"color": "#FFF"
},
"require": {
"igniter.cart": "*",
"igniter.local": "*",
"igniter.user": "*",
"igniter.reservation": "*"
},
"homepage": "https://tastyigniter.com/marketplace/item/igniterlabs-webhook"
}
},
"scripts": {
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint",
"static": "vendor/bin/phpstan analyse --ansi --memory-limit 1056M"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true,
"composer/installers": true
},
"autoload": {
"psr-4": {
"IgniterLabs\\Webhook\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"IgniterLabs\\Webhook\\Tests\\": "tests/"
}
},
"extra": {
"tastyigniter-extension": {
"code": "igniterlabs.webhook",
"name": "Webhooks",
"icon": {
"image": "icon.svg",
"backgroundColor": "#147EFB",
"color": "#FFF"
},
"require": {
"igniter.cart": "*",
"igniter.local": "*",
"igniter.user": "*",
"igniter.reservation": "*"
},
"homepage": "https://tastyigniter.com/marketplace/item/igniterlabs-webhook"
}
},
"scripts": {
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint",
"static": "vendor/bin/phpstan analyse --ansi --memory-limit 1056M"
},
"config": {
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true,
"composer/installers": true
},
"sort-packages": true
},
"minimum-stability": "dev"
"sort-packages": true
},
"minimum-stability": "dev"
}
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:YzE5YjR2b3hrem1ucmdmc2Fkbm92NW1veHBkMWdpa3k="/>
<env name="DB_DATABASE" value="testbench"/>
</php>
<source>
<include>
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Outgoing.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function dispatchWebhook($actionCode, $eventCode)
'event_code' => $eventCode,
]);

Event::fire('igniterlabs.webhook.beforeDispatch', [$webhookJob, $this]);
Event::dispatch('igniterlabs.webhook.beforeDispatch', [$webhookJob, $this]);

$webhookJob->dispatch();
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<?php

uses(SamPoyigi\Testbench\TestCase::class)->in(__DIR__);
31 changes: 31 additions & 0 deletions tests/WebhookEvents/CategoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace IgniterLabs\Webhook\Tests\WebhookEvents;

use IgniterLabs\Webhook\Classes\WebhookManager;
use IgniterLabs\Webhook\Models\Outgoing;
use IgniterLabs\Webhook\WebhookEvents\Category;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Queue;

it('runs category webhook event', function ($action) {
Queue::fake();
Event::fake();

Outgoing::create([
'name' => 'Category created',
'url' => 'http://webhook.tld',
'events' => ['category'],
'is_active' => true,
]);

$actionCode = 'created';
$payload = Category::makePayloadFromEvent([], $actionCode);
resolve(WebhookManager::class)->runWebhookEvent(
'category', $actionCode, $payload ?? []
);

Event::assertDispatched('igniterlabs.webhook.beforeDispatch');
})->with([
'created'
]);
2 changes: 0 additions & 2 deletions tests/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use IgniterLabs\Webhook\Jobs\CallWebhook;
use Illuminate\Support\Facades\Queue;

uses(TestCase::class);

beforeEach(function () {
Queue::fake();
});
Expand Down
23 changes: 0 additions & 23 deletions tests/webhookevents/CategoryTest.php

This file was deleted.

0 comments on commit 94a0963

Please sign in to comment.