-
-
Notifications
You must be signed in to change notification settings - Fork 16
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 #10 from renoki-co/feature/actions
[feature] Improved Code & CI
- Loading branch information
Showing
13 changed files
with
276 additions
and
63 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_size = 2 |
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,35 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php: ['7.0', '7.1', '7.2', '7.3', '7.4'] | ||
name: PHP ${{ matrix.php }} | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/cache@v1 | ||
name: Cache dependencies | ||
with: | ||
path: ~/.composer/cache/files | ||
key: composer-php-${{ matrix.php }}-${{ hashFiles('composer.json') }} | ||
- name: Install dependencies | ||
run: | | ||
composer install --no-interaction --prefer-source | ||
- name: Run tests | ||
run: | | ||
phpunit --coverage-text --coverage-clover=coverage.xml | ||
- uses: codecov/codecov-action@v1 | ||
with: | ||
fail_ci_if_error: true |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
"authors": [ | ||
{ | ||
"name": "Alex Renoki", | ||
"email": "[email protected]", | ||
"homepage": "https://github.com/rennokki", | ||
"role": "Developer" | ||
} | ||
|
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
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,76 @@ | ||
<?php | ||
|
||
namespace Rennokki\LaravelSnsEvents\Tests; | ||
|
||
use Illuminate\Support\Facades\Event; | ||
use Rennokki\LaravelSnsEvents\Events\SnsEvent; | ||
use Rennokki\LaravelSnsEvents\Events\SnsSubscriptionConfirmation; | ||
|
||
class EventTest extends TestCase | ||
{ | ||
public function test_no_event_triggering_on_bad_request() | ||
{ | ||
Event::fake(); | ||
|
||
$this | ||
->json('GET', route('sns')) | ||
->assertSee('OK'); | ||
|
||
Event::assertNotDispatched(SnsEvent::class); | ||
Event::assertNotDispatched(SnsSubscriptionConfirmation::class); | ||
} | ||
|
||
public function test_subscription_confirmation() | ||
{ | ||
Event::fake(); | ||
|
||
$this | ||
->withHeaders([ | ||
'x-test-header' => 1, | ||
]) | ||
->json('POST', route('sns'), $this->getSubscriptionConfirmationPayload()) | ||
->assertSee('OK'); | ||
|
||
Event::assertNotDispatched(SnsEvent::class); | ||
|
||
Event::assertDispatched(SnsSubscriptionConfirmation::class, function ($event) { | ||
$this->assertTrue( | ||
isset($event->headers['x-test-header']) | ||
); | ||
|
||
return true; | ||
}); | ||
} | ||
|
||
public function test_notification_confirmation() | ||
{ | ||
Event::fake(); | ||
|
||
$message = json_encode([ | ||
'test' => 1, | ||
'sns' => true, | ||
]); | ||
|
||
$this | ||
->withHeaders([ | ||
'x-test-header' => 1, | ||
]) | ||
->json('POST', route('sns'), $this->getNotificationPayload($message)) | ||
->assertSee('OK'); | ||
|
||
Event::assertNotDispatched(SnsSubscriptionConfirmation::class); | ||
|
||
Event::assertDispatched(SnsEvent::class, function ($event) { | ||
$this->assertTrue( | ||
isset($event->headers['x-test-header']) | ||
); | ||
|
||
$message = json_decode($event->message['Message'], true); | ||
|
||
$this->assertEquals(1, $message['test']); | ||
$this->assertEquals(true, $message['sns']); | ||
|
||
return true; | ||
}); | ||
} | ||
} |
Oops, something went wrong.