Skip to content

Commit

Permalink
Merge pull request #9 from arthurkirkosa/revert-console
Browse files Browse the repository at this point in the history
Revert console
  • Loading branch information
binaryk authored Dec 15, 2020
2 parents 44af0c8 + 355dd3b commit 53122eb
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 44 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Tests

on: [push, pull_request]
on:
push:
pull_request:
types: [opened]

jobs:
test:
Expand All @@ -9,7 +12,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [7.4]
php: [7.4, 8.0]
laravel: [^7.0, ^8.0]
dependency-version: [prefer-lowest, prefer-stable]
include:
Expand All @@ -22,21 +25,21 @@ jobs:

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') }}
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none

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

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
],
"require": {
"php": "^7.4"
"php": "^7.4|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
Expand Down
37 changes: 11 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="BinarCode Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="BinarCode Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
6 changes: 1 addition & 5 deletions src/Models/BelongsToTenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace BinarCode\Tenantable\Models;

use Illuminate\Support\Facades\App;

/**
* Trait BelongsToTenant
* @package BinarCode\Tenantable\Models
Expand All @@ -20,9 +18,7 @@ public function tenant()

public static function bootBelongsToTenant()
{
if (! App::runningInConsole()) {
static::addGlobalScope(new TenantScope);
}
static::addGlobalScope(new TenantScope);

static::creating(function ($model) {
if (! $model->getAttribute(BelongsToTenant::$tenantIdColumn) && ! $model->relationLoaded('tenant')) {
Expand Down
2 changes: 2 additions & 0 deletions src/Models/Concerns/HasScopedValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace BinarCode\Tenantable\Models\Concerns;

use BinarCode\Tenantable\Models\BelongsToTenant;
use Illuminate\Validation\Rules\Exists;
use Illuminate\Validation\Rules\Unique;

/**
* @package BinarCode\Tenantable\Models\Concerns;
Expand Down
1 change: 0 additions & 1 deletion src/Models/Tenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public static function current(): ?Tenant
{
$containerKey = config('tenantable.container_key');


if (! app()->has($containerKey)) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Models/TenantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TenantTest extends TestCase
{
public function test_it_can_create_a_model()
{
/** * @var Tenant $tenant */
/** @var Tenant $tenant */
$tenant = Tenant::create([
'name' => 'Binar Code Building',
'subdomain' => 'sample',
Expand Down
8 changes: 8 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public function setUp(): void
parent::setUp();

$this->withFactories(__DIR__.'/database/factories');

$this->setUpDatabase();
}

protected function getPackageProviders($app)
Expand All @@ -31,7 +33,13 @@ public function getEnvironmentSetUp($app)
'prefix' => '',
]);

$app['config']->set('tenantable.master_database_connection_name', 'master');
}

protected function setUpDatabase()
{
include_once __DIR__.'/../database/migrations/create_tenantable_tables.php.stub';

(new \CreateTenantableTables())->up();
}
}

0 comments on commit 53122eb

Please sign in to comment.