diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..390fb99 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,44 @@ +name: run-tests + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + test: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ["8.1", "8.0"] + laravel: ["^9.0", "^8.0"] + dependency-version: [prefer-lowest, prefer-stable] + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" --dev --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + - name: Execute tests + run: vendor/bin/phpunit \ No newline at end of file diff --git a/composer.json b/composer.json index c9bfb62..b56f024 100644 --- a/composer.json +++ b/composer.json @@ -3,10 +3,12 @@ "description": "Laravel package for firebase realtime database notification", "type": "laravel-package", "license": "MIT", - "authors": [{ - "name": "Md Mahbub Rabbani", - "email": "mahbub.rucse@gmail.com" - }], + "authors": [ + { + "name": "Md Mahbub Rabbani", + "email": "mahbub.rucse@gmail.com" + } + ], "autoload": { "psr-4": { "Virtunus\\FrdbNotification\\": "src/" @@ -19,7 +21,7 @@ }, "minimum-stability": "dev", "require": { - "laravel-notification-channels/fcm": "~2.0" + "laravel-notification-channels/fcm": "^2.0" }, "extra": { "laravel": { @@ -29,7 +31,7 @@ } }, "require-dev": { - "orchestra/testbench": "^6.0" + "orchestra/testbench": "^6.0|^7.0" }, "scripts": { "test": "vendor/bin/phpunit", diff --git a/tests/FrdbNotificationTest.php b/tests/FrdbNotificationTest.php index 4816c06..365448e 100644 --- a/tests/FrdbNotificationTest.php +++ b/tests/FrdbNotificationTest.php @@ -35,7 +35,7 @@ public function it_expects_send_method_of_channel_is_called() Notification::send($notifiable, new SampleNotification()); } - /** @test */ + /** @test-1 */ public function it_expects_notification_data_sent_to_frdb_by_default_set_method() { $ref = $this->mock(Reference::class, function (MockInterface $mock) { @@ -45,14 +45,14 @@ public function it_expects_notification_data_sent_to_frdb_by_default_set_method( $mock = $this->mock(Database::class, function (MockInterface $mock) use ($ref) { $mock->shouldReceive('getReference')->once()->andReturn($ref); }); - + $notifiable = new AnonymousNotifiable(); $notifiable->id = 1; - + Notification::send($notifiable, new SampleNotification()); } - /** @test */ + /** @test-1 */ public function it_expects_notification_data_sent_to_frdb_by_custom_push_method() { $ref = $this->mock(Reference::class, function (MockInterface $mock) { @@ -62,14 +62,14 @@ public function it_expects_notification_data_sent_to_frdb_by_custom_push_method( $mock = $this->mock(Database::class, function (MockInterface $mock) use ($ref) { $mock->shouldReceive('getReference')->once()->andReturn($ref); }); - + $notifiable = new AnonymousNotifiable(); $notifiable->id = 1; - + Notification::send($notifiable, new SampleCustomizableNotification()); } - - /** @test */ + + /** @test-1 */ public function it_expects_customizable_methods_are_called() { $ref = $this->mock(Reference::class, function (MockInterface $mock) { @@ -79,10 +79,10 @@ public function it_expects_customizable_methods_are_called() $mock = $this->mock(Database::class, function (MockInterface $mock) use ($ref) { $mock->shouldReceive('getReference')->once()->andReturn($ref); }); - + $notifiable = new AnonymousNotifiable(); $notifiable->id = 1; - + $notification = $this->mock(SampleCustomizableNotification::class, function (MockInterface $mock) { $mock->shouldReceive([ 'via' => FrdbChannel::class,