Skip to content

Commit

Permalink
Merge pull request #66 from fico7489/filip-patch
Browse files Browse the repository at this point in the history
Filip patch
  • Loading branch information
fico7489 authored Mar 26, 2020
2 parents 11b7609 + 83259aa commit 242de0e
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 23 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test

on:
pull_request:
push:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: [7.2]
laravel_version: [5.5.*,6.*, 7.*]

steps:
- name: Checkout commit
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php_version }}

- name: Validate composer.json
run: composer validate

- name: Run composer install
run: composer install --no-interaction --no-suggest

- name: Install Laravel
run: composer update --no-interaction illuminate/database:^${{ matrix.laravel_version }}

- name: Run PHPUnit
run: ./vendor/bin/phpunit
6 changes: 0 additions & 6 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ return Config::create()
->setRules([
'@PSR2' => true,
'@Symfony' => true,

'align_multiline_comment' => true,
'blank_line_after_opening_tag' => true,
'single_blank_line_before_namespace' => true,
'no_unused_imports' => true,
'binary_operator_spaces' => ['default' => null],
])
->setFinder($finder)
;
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":2859:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:32:{s:62:"Fico7489\Laravel\Pivot\Tests\ObservableEventsTest::test_events";d:0.19;s:65:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_attach_int";d:0.021;s:77:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_attach_int";d:0.015;s:68:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_attach_string";d:0.014;s:67:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_attach_array";d:0.015;s:79:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_attach_array";d:0.014;s:67:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_attach_model";d:0.015;s:79:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_attach_model";d:0.015;s:72:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_attach_collection";d:0.015;s:84:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_attach_collection";d:0.014;s:65:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_detach_int";d:0.014;s:77:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_detach_int";d:0.015;s:67:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_detach_array";d:0.014;s:79:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_detach_array";d:0.014;s:67:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_detach_model";d:0.014;s:79:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_detach_model";d:0.015;s:72:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_detach_collection";d:0.015;s:84:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_detach_collection";d:0.014;s:66:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_detach_null";d:0.015;s:78:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_detach_null";d:0.019;s:61:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_update";d:0.015;s:73:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_update";d:0.014;s:63:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_sync_int";d:0.015;s:75:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_sync_int";d:0.014;s:65:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_sync_array";d:0.015;s:77:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_sync_array";d:0.015;s:65:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_sync_model";d:0.015;s:77:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_sync_model";d:0.015;s:70:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_sync_collection";d:0.015;s:82:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_polymorphic_sync_collection";d:0.015;s:70:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_standard_update";d:0.014;s:71:"Fico7489\Laravel\Pivot\Tests\PivotEventTraitTest::test_relation_is_null";d:0.014;}}}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
}
],
"require": {
"illuminate/database": ">5.5.0 || 6.*"
"illuminate/database": "^5.5|^6.0|^7.0"
},
"require-dev": {
"orchestra/testbench": ">3.0",
"friendsofphp/php-cs-fixer": ">2.0"
"orchestra/testbench": "*",
"friendsofphp/php-cs-fixer": "*"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Relations/MorphToManyCustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Fico7489\Laravel\Pivot\Relations;

use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Fico7489\Laravel\Pivot\Traits\FiresPivotEventsTrait;
use Illuminate\Database\Eloquent\Relations\MorphToMany;

class MorphToManyCustom extends MorphToMany
{
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/ExtendRelationsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Fico7489\Laravel\Pivot\Traits;

use Fico7489\Laravel\Pivot\Relations\BelongsToManyCustom;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Fico7489\Laravel\Pivot\Relations\MorphToManyCustom;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

trait ExtendRelationsTrait
{
Expand Down
4 changes: 1 addition & 3 deletions src/Traits/FiresPivotEventsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

namespace Fico7489\Laravel\Pivot\Traits;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

trait FiresPivotEventsTrait
{
/**
* Attach a model to the parent.
*
* @param mixed $id
* @param array $attributes
* @param bool $touch
*/
public function attach($ids, array $attributes = [], $touch = true)
Expand Down Expand Up @@ -52,7 +51,6 @@ public function detach($ids = null, $touch = true)
* Update an existing pivot record on the table.
*
* @param mixed $id
* @param array $attributes
* @param bool $touch
*
* @return int
Expand Down
4 changes: 2 additions & 2 deletions tests/PivotEventTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Fico7489\Laravel\Pivot\Tests;

use Fico7489\Laravel\Pivot\Tests\Models\Tag;
use Fico7489\Laravel\Pivot\Tests\Models\Post;
use Fico7489\Laravel\Pivot\Tests\Models\Role;
use Fico7489\Laravel\Pivot\Tests\Models\Seller;
use Fico7489\Laravel\Pivot\Tests\Models\Tag;
use Fico7489\Laravel\Pivot\Tests\Models\User;
use Fico7489\Laravel\Pivot\Tests\Models\Video;
use Fico7489\Laravel\Pivot\Tests\Models\Seller;

class PivotEventTraitTest extends TestCase
{
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Fico7489\Laravel\Pivot\Tests;

use Fico7489\Laravel\Pivot\Tests\Models\Tag;
use Fico7489\Laravel\Pivot\Tests\Models\Post;
use Fico7489\Laravel\Pivot\Tests\Models\Role;
use Fico7489\Laravel\Pivot\Tests\Models\Seller;
use Fico7489\Laravel\Pivot\Tests\Models\Tag;
use Fico7489\Laravel\Pivot\Tests\Models\User;
use Fico7489\Laravel\Pivot\Tests\Models\Video;
use Fico7489\Laravel\Pivot\Tests\Models\Seller;

abstract class TestCase extends \Orchestra\Testbench\TestCase
{
Expand Down Expand Up @@ -42,7 +42,7 @@ public function setUp(): void
$this->assertEquals(0, \DB::table('taggables')->count());

\Event::listen('eloquent.*', function ($eventName, array $data) {
if (0 !== strpos($eventName, 'eloquent.retrieved') && 0 !== strpos($eventName, 'eloquent.booting') && 0 !== strpos($eventName, 'eloquent.booted')) {
if (0 !== strpos($eventName, 'eloquent.retrieved') && 0 !== strpos($eventName, 'eloquent.booting') && 0 !== strpos($eventName, 'eloquent.booted')) {
self::$events[] = ['name' => $eventName, 'model' => $data['model'], 'relation' => $data['relation'], 'pivotIds' => $data['pivotIds'], 'pivotIdsAttributes' => $data['pivotIdsAttributes']];
}
});
Expand All @@ -53,9 +53,9 @@ protected function getEnvironmentSetUp($app)
// Setup default database to use sqlite :memory:
$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
'prefix' => '',
]);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

/**
* Class CreateDatabase.
Expand Down

0 comments on commit 242de0e

Please sign in to comment.