Merge pull request #2 from superhelio/feat/maintenance-2021

Updated requirements
This commit is contained in:
2021-01-21 12:33:36 +02:00
committed by GitHub
13 changed files with 4362 additions and 1141 deletions

View File

@@ -1,7 +1,8 @@
language: php language: php
php: php:
- 7.0 - 7.3
- 7.1 - 7.4
- 8.0
- nightly - nightly
matrix: matrix:
allow_failures: allow_failures:
@@ -17,4 +18,4 @@ install:
- flags="--ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress" - flags="--ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress"
- travis_wait 30 composer install $flags - travis_wait 30 composer install $flags
script: script:
- ./vendor/bin/phpunit -c phpunit.xml - ./vendor/bin/phpunit -c phpunit.xml

View File

@@ -1,4 +1,4 @@
# Laravel Commands by [SuperHelio](link-author) # Laravel Commands by [SuperHelio][link-author]
[![Latest Version on Packagist][ico-version]][link-packagist] [![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md) [![Software License][ico-license]](LICENSE.md)
@@ -10,7 +10,7 @@
This is a collection of Laravel Artisan commands created to help everyone This is a collection of Laravel Artisan commands created to help everyone
in their development work. We try to keep these as useful as possible. in their development work. We try to keep these as useful as possible.
This package requires PHP 7.0 or later. `composer.lock` has been generated with PHP v7.0.23. This package requires PHP 7.3 or later. The `composer.lock` file has been generated with PHP v7.4.13.
## Install ## Install
@@ -27,7 +27,7 @@ You'll only want to use these generators for local development, so you don't wan
```php ```php
public function register() public function register()
{ {
if ($this->app->environment() == 'local') { if ($this->app->environment() === 'local') {
$this->app->register('SuperHelio\Commands\ServiceProvider'); $this->app->register('SuperHelio\Commands\ServiceProvider');
} }
} }

View File

@@ -17,13 +17,14 @@
} }
], ],
"require": { "require": {
"php" : ">=7.0", "php" : ">=7.3",
"illuminate/support": "^5.3|^5.4|^5.5", "illuminate/support": "^5.3|^6.0|^7.0|^8.0",
"doctrine/dbal": "^2.5|^2.6" "doctrine/dbal": "^2.5|^2.6"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit" : "^5.0", "roave/security-advisories": "dev-master",
"orchestra/testbench": "~3.0" "phpunit/phpunit" : "^8.0",
"orchestra/testbench": "^3.3|^4|^5|^6"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

5371
composer.lock generated

File diff suppressed because it is too large Load Diff

19
phpcs.xml Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<ruleset name="Project"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>Project PHP Code Style Rules</description>
<file>src</file>
<file>tests</file>
<arg name="basepath" value="."/>
<arg name="colors"/>
<arg name="parallel" value="75"/>
<arg value="np"/>
<exclude-pattern>*/.git/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<rule ref="PSR2" />
</ruleset>

View File

@@ -7,8 +7,7 @@
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false">
syntaxCheck="false">
<testsuites> <testsuites>
<testsuite name="Superhelio\Commands Test Suite"> <testsuite name="Superhelio\Commands Test Suite">
@@ -24,4 +23,4 @@
<directory suffix=".php">src/</directory> <directory suffix=".php">src/</directory>
</whitelist> </whitelist>
</filter> </filter>
</phpunit> </phpunit>

View File

@@ -5,6 +5,7 @@ namespace Superhelio\Commands\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
class Gozer extends Command class Gozer extends Command
{ {
@@ -134,14 +135,12 @@ class Gozer extends Command
{ {
try { try {
/** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $connection */ /** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $connection */
$connection = app('db')->connection()->getDoctrineSchemaManager(); return app('db')->connection()->getDoctrineSchemaManager();
} catch (\Exception $e) { } catch (\Exception $e) {
$this->error($e->getMessage()); $this->error($e->getMessage());
return false; return false;
} }
return $connection;
} }
/** /**
@@ -165,7 +164,7 @@ class Gozer extends Command
public function getDatabasePrefix() public function getDatabasePrefix()
{ {
return trim(DB::getTablePrefix()); return trim(DB::connection()->getTablePrefix());
} }
/** /**
@@ -179,7 +178,7 @@ class Gozer extends Command
} }
/** /**
* @param array $tables * @param array|\Illuminate\Support\Collection $tables
* *
* @return \Illuminate\Support\Collection * @return \Illuminate\Support\Collection
*/ */
@@ -188,7 +187,7 @@ class Gozer extends Command
$prefix = $this->dbPrefix; $prefix = $this->dbPrefix;
return collect($tables)->reject(function ($table) use ($prefix) { return collect($tables)->reject(function ($table) use ($prefix) {
return !starts_with($table, $prefix); return !Str::startsWith($table, $prefix);
}); });
} }
} }

View File

@@ -48,5 +48,7 @@ class Reload extends Command
return true; return true;
} }
return false;
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
namespace Superhelio\Commands; namespace Superhelio\Commands;
class Facade extends \Illuminate\Support\Facades\Facade class Facade extends \Illuminate\Support\Facades\Facade

View File

@@ -36,7 +36,7 @@ class ServiceProvider extends BaseServiceProvider
private function registerReloader() private function registerReloader()
{ {
$this->app->singleton('command.superhelio.reload', function ($app) { $this->app->singleton('command.superhelio.reload', function ($app) {
return $app['Superhelio\Commands\Commands\Reload']; return $app[\Superhelio\Commands\Commands\Reload::class];
}); });
$this->commands('command.superhelio.reload'); $this->commands('command.superhelio.reload');
} }
@@ -44,7 +44,7 @@ class ServiceProvider extends BaseServiceProvider
private function registerGozer() private function registerGozer()
{ {
$this->app->singleton('command.superhelio.gozer', function ($app) { $this->app->singleton('command.superhelio.gozer', function ($app) {
return $app['Superhelio\Commands\Commands\Gozer']; return $app[\Superhelio\Commands\Commands\Gozer::class];
}); });
$this->commands('command.superhelio.gozer'); $this->commands('command.superhelio.gozer');
} }

View File

@@ -1,5 +1,6 @@
<?php <?php
namespace Superhelio\Commands;
namespace Superhelio\Commands\Tests;
use ReflectionClass; use ReflectionClass;
use Superhelio\Commands\Commands\Gozer; use Superhelio\Commands\Commands\Gozer;
@@ -11,7 +12,7 @@ class GozerTest extends \Orchestra\Testbench\TestCase
/** /**
* Setup the test environment. * Setup the test environment.
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->artisan('migrate', ['--database' => 'testbench']); $this->artisan('migrate', ['--database' => 'testbench']);
@@ -20,7 +21,7 @@ class GozerTest extends \Orchestra\Testbench\TestCase
/** /**
* Define environment setup. * Define environment setup.
* *
* @param \Illuminate\Foundation\Application $app * @param \Illuminate\Foundation\Application $app
* *
* @return void * @return void
*/ */
@@ -42,15 +43,15 @@ class GozerTest extends \Orchestra\Testbench\TestCase
* In a normal app environment these would be added to * In a normal app environment these would be added to
* the 'providers' array in the config/app.php file. * the 'providers' array in the config/app.php file.
* *
* @param \Illuminate\Foundation\Application $app * @param \Illuminate\Foundation\Application $app
* *
* @return array * @return array
*/ */
protected function getPackageProviders($app) protected function getPackageProviders($app)
{ {
return [ return [
'\Superhelio\Commands\Tests\Stubs\ServiceProvider', \Superhelio\Commands\Tests\Stubs\ServiceProvider::class,
'\Superhelio\Commands\ServiceProvider' \Superhelio\Commands\ServiceProvider::class
]; ];
} }
@@ -63,35 +64,35 @@ class GozerTest extends \Orchestra\Testbench\TestCase
]); ]);
$users = DB::table('users')->where('id', '=', 1)->first(); $users = DB::table('users')->where('id', '=', 1)->first();
$this->assertEquals('hello@gozer.dev', $users->email); self::assertEquals('hello@gozer.dev', $users->email);
$this->assertEquals('User name', $users->name); self::assertEquals('User name', $users->name);
$this->assertTrue(Hash::check('123', $users->password)); self::assertTrue(Hash::check('123', $users->password));
} }
public function test_dbal_is_installed() public function test_dbal_is_installed()
{ {
$this->assertTrue(class_exists('\\Doctrine\\DBAL\\Schema\\Schema')); self::assertTrue(class_exists('\\Doctrine\\DBAL\\Schema\\Schema'));
} }
public function test_gozer_is_installed() public function test_gozer_is_installed()
{ {
$this->assertTrue(class_exists('\\Superhelio\\Commands\\Commands\\Gozer')); self::assertTrue(class_exists('\\Superhelio\\Commands\\Commands\\Gozer'));
} }
public function test_gozer_has_required_methods_and_properties() public function test_gozer_has_required_methods_and_properties()
{ {
$gozer = new ReflectionClass('\\Superhelio\\Commands\\Commands\\Gozer'); $gozer = new ReflectionClass('\\Superhelio\\Commands\\Commands\\Gozer');
$this->assertTrue($gozer->hasMethod('handle')); self::assertTrue($gozer->hasMethod('handle'));
$this->assertTrue($gozer->hasProperty('signature')); self::assertTrue($gozer->hasProperty('signature'));
$this->assertTrue($gozer->hasProperty('description')); self::assertTrue($gozer->hasProperty('description'));
$this->assertTrue($gozer->hasProperty('dbPrefix')); self::assertTrue($gozer->hasProperty('dbPrefix'));
} }
public function test_gozer_finds_database_prefix() public function test_gozer_finds_database_prefix()
{ {
$gozer = new Gozer(); $gozer = new Gozer();
$this->assertEquals('gozerTest__', $gozer->getDatabasePrefix()); self::assertEquals('gozerTest__', $gozer->getDatabasePrefix());
} }
public function test_gozer_finds_users_table() public function test_gozer_finds_users_table()
@@ -101,12 +102,12 @@ class GozerTest extends \Orchestra\Testbench\TestCase
$connection = $gozer->getConnection(); $connection = $gozer->getConnection();
$tables = $gozer->getTables($connection); $tables = $gozer->getTables($connection);
$this->assertTrue(in_array('gozerTest__users', $tables, false)); self::assertContains('gozerTest__users', $tables);
$gozer->setDatabasePrefix('gozerTest__'); $gozer->setDatabasePrefix('gozerTest__');
$filteredTables = $gozer->getFilteredTables($tables); $filteredTables = $gozer->getFilteredTables($tables);
$this->assertTrue(is_a($filteredTables, \Illuminate\Support\Collection::class)); self::assertTrue(is_a($filteredTables, \Illuminate\Support\Collection::class));
$this->assertTrue(in_array('gozerTest__users', $filteredTables->toArray(), false)); self::assertContains('gozerTest__users', $filteredTables->toArray());
} }
public function test_gozer_table_filtering_works() public function test_gozer_table_filtering_works()
@@ -123,9 +124,9 @@ class GozerTest extends \Orchestra\Testbench\TestCase
$filtered = $gozer->getFilteredTables($tables); $filtered = $gozer->getFilteredTables($tables);
$array = $filtered->toArray(); $array = $filtered->toArray();
$this->assertFalse(in_array('this_should_be_filtered', $array, false)); self::assertNotContains('this_should_be_filtered', $array);
$this->assertFalse(in_array('filter_me_too', $array, false)); self::assertNotContains('filter_me_too', $array);
$this->assertTrue(in_array('gozerTest__users', $array, false)); self::assertContains('gozerTest__users', $array);
$this->assertTrue(in_array('gozerTest__migrations', $array, false)); self::assertContains('gozerTest__migrations', $array);
} }
} }

View File

@@ -1,14 +1,28 @@
<?php <?php
namespace Superhelio\Commands;
namespace Superhelio\Commands\Tests;
use Superhelio\Commands\Commands\Reload; use Superhelio\Commands\Commands\Reload;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
class ReloadTest extends \PHPUnit_Framework_TestCase class ReloadTest extends \Orchestra\Testbench\TestCase
{ {
public function testReloadTest() public function testReloadTest()
{ {
$this->assertTrue(true); self::assertTrue(true);
}
public function test_reload_is_installed()
{
self::assertTrue(class_exists('\\Superhelio\\Commands\\Commands\\Reload'));
}
public function test_reload_has_required_methods_and_properties()
{
$reload = new \ReflectionClass('\\Superhelio\\Commands\\Commands\\Reload');
self::assertTrue($reload->hasMethod('handle'));
self::assertTrue($reload->hasProperty('signature'));
self::assertTrue($reload->hasProperty('description'));
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
namespace Superhelio\Commands\Tests\Stubs; namespace Superhelio\Commands\Tests\Stubs;
class ServiceProvider extends \Illuminate\Support\ServiceProvider class ServiceProvider extends \Illuminate\Support\ServiceProvider