Skip to content

Commit

Permalink
Merge pull request #23 from ARCANEDEV/update-github_actions
Browse files Browse the repository at this point in the history
Using GitHub Actions for testing
  • Loading branch information
arcanedev-maroc authored Feb 7, 2020
2 parents 4277a33 + febcc49 commit d1a6564
Show file tree
Hide file tree
Showing 30 changed files with 236 additions and 196 deletions.
10 changes: 5 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
phpunit.xml.dist export-ignore
CONTRIBUTING.md export-ignore
46 changes: 46 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: run-tests

on: [push]

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4]
laravel: [6.*]
dependency-version: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v1

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: xdebug

- name: Install dependencies
run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest

- name: Execute tests
run: |
mkdir -p build/logs
vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
- name: Scrutinizer CI
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 2
runs: 6
php_code_sniffer:
enabled: true
config:
Expand Down
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Laravel Messenger [![Packagist License][badge_license]](LICENSE.md) [![For Laravel][badge_laravel]][link-github-repo]

[![Travis Status][badge_build]][link-travis]
[![Github Workflow Status][badge_build]][link-github-status]
[![Coverage Status][badge_coverage]][link-scrutinizer]
[![Scrutinizer Code Quality][badge_quality]][link-scrutinizer]
[![SensioLabs Insight][badge_insight]][link-insight]
Expand Down Expand Up @@ -47,7 +47,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.

[badge_laravel]: https://img.shields.io/badge/Laravel-5.1%20to%206.x-orange.svg?style=flat-square
[badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-messenger.svg?style=flat-square
[badge_build]: https://img.shields.io/travis/ARCANEDEV/LaravelMessenger.svg?style=flat-square
[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/LaravelMessenger/run-tests?style=flat-square
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/LaravelMessenger.svg?style=flat-square
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/LaravelMessenger.svg?style=flat-square
[badge_insight]: https://img.shields.io/sensiolabs/i/0fe62754-1219-409a-9d05-b6ae7e3e342f.svg?style=flat-square
Expand All @@ -58,6 +58,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.

[link-author]: https://github.com/arcanedev-maroc
[link-github-repo]: https://github.com/ARCANEDEV/LaravelMessenger
[link-github-status]: https://github.com/ARCANEDEV/LaravelMessenger/actions
[link-github-issues]: https://github.com/ARCANEDEV/LaravelMessenger/issues
[link-contributors]: https://github.com/ARCANEDEV/LaravelMessenger/graphs/contributors
[link-packagist]: https://packagist.org/packages/arcanedev/laravel-messenger
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"license": "MIT",
"require": {
"php": ">=7.2.0",
"arcanedev/support": "^5.0"
"arcanedev/support": "^5.1"
},
"require-dev": {
"orchestra/testbench": "^4.0",
"orchestra/testbench": "^4.6",
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^8.0",
"phpunit/phpcov": "^6.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Arcanedev\LaravelMessenger\Bases\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand All @@ -25,7 +27,7 @@ public function __construct()
parent::__construct();

$this->setTable(
config('messenger.discussions.table', 'discussions')
(string) config('messenger.discussions.table', 'discussions')
);
}

Expand All @@ -37,9 +39,9 @@ public function __construct()
/**
* Run the migrations.
*/
public function up()
public function up(): void
{
$this->createSchema(function (Blueprint $table) {
$this->createSchema(function (Blueprint $table): void {
$table->increments('id');
$table->string('subject')->nullable();
$table->timestamps();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Arcanedev\LaravelMessenger\Bases\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand All @@ -25,7 +27,7 @@ public function __construct()
parent::__construct();

$this->setTable(
config('messenger.messages.table', 'messages')
(string) config('messenger.messages.table', 'messages')
);
}

Expand All @@ -37,9 +39,9 @@ public function __construct()
/**
* Run the migrations.
*/
public function up()
public function up(): void
{
$this->createSchema(function (Blueprint $table) {
$this->createSchema(function (Blueprint $table): void {
$table->increments('id');
$table->unsignedInteger('discussion_id');
$table->morphs(config('messenger.users.morph', 'participable'));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Arcanedev\LaravelMessenger\Bases\Migration;
use Illuminate\Database\Schema\Blueprint;

Expand Down Expand Up @@ -37,9 +39,9 @@ public function __construct()
/**
* Run the migrations.
*/
public function up()
public function up(): void
{
$this->createSchema(function (Blueprint $table) {
$this->createSchema(function (Blueprint $table): void {
$table->increments('id');
$table->unsignedInteger('discussion_id');
$table->morphs(config('messenger.users.morph', 'participable'));
Expand Down
6 changes: 5 additions & 1 deletion src/Bases/Migration.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMessenger\Bases;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMessenger\Bases;

use Arcanedev\Support\Database\Migration as BaseMigration;

Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/Discussion.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMessenger\Contracts;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMessenger\Contracts;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/Message.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMessenger\Contracts;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMessenger\Contracts;

/**
* Interface Message
Expand Down
18 changes: 5 additions & 13 deletions src/Contracts/Participation.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMessenger\Contracts;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMessenger\Contracts;

/**
* Interface Participation
Expand Down Expand Up @@ -49,16 +53,4 @@ public function participable();
* @return string
*/
public function stringInfo();

/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Restore a soft-deleted model instance.
*
* @return bool|null
*/
public function restore();
}
14 changes: 11 additions & 3 deletions src/LaravelMessengerServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMessenger;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMessenger;

use Arcanedev\Support\Providers\PackageServiceProvider;

Expand Down Expand Up @@ -44,9 +48,13 @@ public function register(): void
*/
public function boot(): void
{
$this->publishConfig();
if ($this->app->runningInConsole()) {
$this->publishConfig();

Messenger::$runsMigrations ? $this->loadMigrations() : $this->publishMigrations();
Messenger::$runsMigrations
? $this->loadMigrations()
: $this->publishMigrations();
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Messenger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMessenger;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMessenger;

/**
* Class Messenger
Expand Down
40 changes: 14 additions & 26 deletions src/Models/Discussion.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php namespace Arcanedev\LaravelMessenger\Models;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMessenger\Models;

use Arcanedev\LaravelMessenger\Contracts\Discussion as DiscussionContract;
use Arcanedev\LaravelMessenger\Contracts\Message as MessageContract;
use Arcanedev\LaravelMessenger\Contracts\Participation as ParticipationContract;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model as EloquentModel;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;

Expand All @@ -29,9 +31,8 @@
*
* @method static \Illuminate\Database\Eloquent\Builder|static subject(string $subject, bool $strict)
* @method static \Illuminate\Database\Eloquent\Builder|static between(\Illuminate\Support\Collection|array $participables)
* @method static \Illuminate\Database\Eloquent\Builder|static forUser(\Illuminate\Database\Eloquent\Model $participable)
* @method static \Illuminate\Database\Eloquent\Builder|static withParticipations()
* @method static \Illuminate\Database\Eloquent\Builder|static forUserWithNewMessages(\Illuminate\Database\Eloquent\Model $participable)
* @method static \Illuminate\Database\Eloquent\Builder|static forUser(\Illuminate\Database\Eloquent\Model|mixed $participable)
* @method static \Illuminate\Database\Eloquent\Builder|static forUserWithNewMessages(\Illuminate\Database\Eloquent\Model|mixed $participable)
*/
class Discussion extends Model implements DiscussionContract
{
Expand Down Expand Up @@ -137,27 +138,14 @@ public function creator()
public function scopeForUser(Builder $query, EloquentModel $participable)
{
$table = $this->getParticipationsTable();
$morph = config('messenger.users.morph', 'participable');

return $query->join($table, function (JoinClause $join) use ($table, $participable) {
$morph = config('messenger.users.morph', 'participable');

$join->on($this->getQualifiedKeyName(), '=', "{$table}.discussion_id")
->where("{$table}.{$morph}_type", '=', $participable->getMorphClass())
->where("{$table}.{$morph}_id", '=', $participable->getKey())
->whereNull("{$table}.deleted_at");
});
}

/**
* Scope discussions to load participations relationship.
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public function scopeWithParticipations(Builder $query)
{
return $query->with(['participations']);
return $query
->join($table, $this->getQualifiedKeyName(), '=', "{$table}.discussion_id")
->where("{$table}.{$morph}_type", '=', $participable->getMorphClass())
->where("{$table}.{$morph}_id", '=', $participable->getKey())
->whereNull("{$table}.deleted_at")
->select("{$this->getTable()}.*");
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Models/Message.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMessenger\Models;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMessenger\Models;

use Arcanedev\LaravelMessenger\Contracts\Message as MessageContract;

Expand Down
Loading

0 comments on commit d1a6564

Please sign in to comment.