-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dniccum/feature/logging
Feature/logging
- Loading branch information
Showing
29 changed files
with
722 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
package-lock.json | ||
composer.phar | ||
composer.lock | ||
phpunit.xml | ||
.phpunit.result.cache | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Dniccum\NovaWebhooks\Database\Factories; | ||
|
||
use Dniccum\NovaWebhooks\Models\WebhookLog; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
|
||
class WebhookLogFactory extends Factory | ||
{ | ||
/** | ||
* The name of the factory's corresponding model. | ||
* | ||
* @var string | ||
*/ | ||
protected $model = WebhookLog::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array | ||
*/ | ||
public function definition() | ||
{ | ||
return [ | ||
'successful' => true, | ||
'created_at' => now(), | ||
]; | ||
} | ||
|
||
/** | ||
* @return WebhookLogFactory|\Dniccum\NovaWebhooks\Database\Factories\WebhookLogFactory.state | ||
*/ | ||
public function notFound() | ||
{ | ||
return $this->state(function(array $attributes) { | ||
return [ | ||
'successful' => false, | ||
'error_code' => '404', | ||
'error_message' => 'Page not found.' | ||
]; | ||
}); | ||
} | ||
|
||
/** | ||
* @return WebhookLogFactory|\Dniccum\NovaWebhooks\Database\Factories\WebhookLogFactory.state | ||
*/ | ||
public function failed() | ||
{ | ||
return $this->state(function(array $attributes) { | ||
return [ | ||
'successful' => false, | ||
'error_code' => '422', | ||
'error_message' => $this->faker->text, | ||
]; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateWebhookLogsTable extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('webhook_logs', function (Blueprint $table) { | ||
$table->id(); | ||
$table->boolean('successful') | ||
->default(true); | ||
$table->string('error_code') | ||
->nullable(); | ||
$table->text('error_message') | ||
->nullable(); | ||
$table->unsignedBigInteger('webhook_id') | ||
->nullable(); | ||
$table->foreign('webhook_id') | ||
->references('id') | ||
->on('webhooks'); | ||
$table->timestamp('created_at') | ||
->nullable(); | ||
}); | ||
} | ||
|
||
public function down() | ||
{ | ||
Schema::dropIfExists('webhook_logs'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
cacheResult="true" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="true" | ||
stopOnFailure="false" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">tests/Feature/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="APP_ENV" value="testing"/> | ||
<env name="APP_KEY" value="base64:mIRM5Fpb6DtuRIejBwkqpt3c/ovlFZsSpo66efwo3g0="/> | ||
<env name="BCRYPT_ROUNDS" value="4"/> | ||
<env name="DB_CONNECTION" value="sqlite"/> | ||
<env name="DB_DATABASE" value=":memory:"/> | ||
<env name="CACHE_DRIVER" value="array"/> | ||
<env name="SESSION_DRIVER" value="array"/> | ||
<env name="QUEUE_DRIVER" value="sync"/> | ||
<env name="MAIL_DRIVER" value="array"/> | ||
<env name="MAIL_MAILER" value="array"/> | ||
<env name="NOVA_WEBHOOKS_LOGGING_ENABLED" value="true"/> | ||
<server name="TELESCOPE_ENABLED" value="false"/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'not_found' => 'The requested endpoint could not be found.' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.