mirror of
https://github.com/superhelio/commands.git
synced 2026-01-26 03:33:59 +00:00
Merge pull request #2 from superhelio/feat/maintenance-2021
Updated requirements
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
language: php
|
||||
php:
|
||||
- 7.0
|
||||
- 7.1
|
||||
- 7.3
|
||||
- 7.4
|
||||
- 8.0
|
||||
- nightly
|
||||
matrix:
|
||||
allow_failures:
|
||||
@@ -17,4 +18,4 @@ install:
|
||||
- flags="--ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress"
|
||||
- travis_wait 30 composer install $flags
|
||||
script:
|
||||
- ./vendor/bin/phpunit -c phpunit.xml
|
||||
- ./vendor/bin/phpunit -c phpunit.xml
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Laravel Commands by [SuperHelio](link-author)
|
||||
# Laravel Commands by [SuperHelio][link-author]
|
||||
|
||||
[![Latest Version on Packagist][ico-version]][link-packagist]
|
||||
[![Software License][ico-license]](LICENSE.md)
|
||||
@@ -10,7 +10,7 @@
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
@@ -27,7 +27,7 @@ You'll only want to use these generators for local development, so you don't wan
|
||||
```php
|
||||
public function register()
|
||||
{
|
||||
if ($this->app->environment() == 'local') {
|
||||
if ($this->app->environment() === 'local') {
|
||||
$this->app->register('SuperHelio\Commands\ServiceProvider');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php" : ">=7.0",
|
||||
"illuminate/support": "^5.3|^5.4|^5.5",
|
||||
"php" : ">=7.3",
|
||||
"illuminate/support": "^5.3|^6.0|^7.0|^8.0",
|
||||
"doctrine/dbal": "^2.5|^2.6"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit" : "^5.0",
|
||||
"orchestra/testbench": "~3.0"
|
||||
"roave/security-advisories": "dev-master",
|
||||
"phpunit/phpunit" : "^8.0",
|
||||
"orchestra/testbench": "^3.3|^4|^5|^6"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
5371
composer.lock
generated
5371
composer.lock
generated
File diff suppressed because it is too large
Load Diff
19
phpcs.xml
Normal file
19
phpcs.xml
Normal 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>
|
||||
@@ -7,8 +7,7 @@
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false">
|
||||
stopOnFailure="false">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Superhelio\Commands Test Suite">
|
||||
@@ -24,4 +23,4 @@
|
||||
<directory suffix=".php">src/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
</phpunit>
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Superhelio\Commands\Commands;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Gozer extends Command
|
||||
{
|
||||
@@ -134,14 +135,12 @@ class Gozer extends Command
|
||||
{
|
||||
try {
|
||||
/** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $connection */
|
||||
$connection = app('db')->connection()->getDoctrineSchemaManager();
|
||||
return app('db')->connection()->getDoctrineSchemaManager();
|
||||
} catch (\Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +164,7 @@ class Gozer extends Command
|
||||
|
||||
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
|
||||
*/
|
||||
@@ -188,7 +187,7 @@ class Gozer extends Command
|
||||
$prefix = $this->dbPrefix;
|
||||
|
||||
return collect($tables)->reject(function ($table) use ($prefix) {
|
||||
return !starts_with($table, $prefix);
|
||||
return !Str::startsWith($table, $prefix);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,5 +48,7 @@ class Reload extends Command
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Superhelio\Commands;
|
||||
|
||||
class Facade extends \Illuminate\Support\Facades\Facade
|
||||
|
||||
@@ -36,7 +36,7 @@ class ServiceProvider extends BaseServiceProvider
|
||||
private function registerReloader()
|
||||
{
|
||||
$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');
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class ServiceProvider extends BaseServiceProvider
|
||||
private function registerGozer()
|
||||
{
|
||||
$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');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace Superhelio\Commands;
|
||||
|
||||
namespace Superhelio\Commands\Tests;
|
||||
|
||||
use ReflectionClass;
|
||||
use Superhelio\Commands\Commands\Gozer;
|
||||
@@ -11,7 +12,7 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
/**
|
||||
* Setup the test environment.
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->artisan('migrate', ['--database' => 'testbench']);
|
||||
@@ -20,7 +21,7 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
/**
|
||||
* Define environment setup.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -42,15 +43,15 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
* In a normal app environment these would be added to
|
||||
* the 'providers' array in the config/app.php file.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [
|
||||
'\Superhelio\Commands\Tests\Stubs\ServiceProvider',
|
||||
'\Superhelio\Commands\ServiceProvider'
|
||||
\Superhelio\Commands\Tests\Stubs\ServiceProvider::class,
|
||||
\Superhelio\Commands\ServiceProvider::class
|
||||
];
|
||||
}
|
||||
|
||||
@@ -63,35 +64,35 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
]);
|
||||
|
||||
$users = DB::table('users')->where('id', '=', 1)->first();
|
||||
$this->assertEquals('hello@gozer.dev', $users->email);
|
||||
$this->assertEquals('User name', $users->name);
|
||||
$this->assertTrue(Hash::check('123', $users->password));
|
||||
self::assertEquals('hello@gozer.dev', $users->email);
|
||||
self::assertEquals('User name', $users->name);
|
||||
self::assertTrue(Hash::check('123', $users->password));
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$gozer = new ReflectionClass('\\Superhelio\\Commands\\Commands\\Gozer');
|
||||
$this->assertTrue($gozer->hasMethod('handle'));
|
||||
$this->assertTrue($gozer->hasProperty('signature'));
|
||||
$this->assertTrue($gozer->hasProperty('description'));
|
||||
$this->assertTrue($gozer->hasProperty('dbPrefix'));
|
||||
self::assertTrue($gozer->hasMethod('handle'));
|
||||
self::assertTrue($gozer->hasProperty('signature'));
|
||||
self::assertTrue($gozer->hasProperty('description'));
|
||||
self::assertTrue($gozer->hasProperty('dbPrefix'));
|
||||
}
|
||||
|
||||
public function test_gozer_finds_database_prefix()
|
||||
{
|
||||
$gozer = new Gozer();
|
||||
|
||||
$this->assertEquals('gozerTest__', $gozer->getDatabasePrefix());
|
||||
self::assertEquals('gozerTest__', $gozer->getDatabasePrefix());
|
||||
}
|
||||
|
||||
public function test_gozer_finds_users_table()
|
||||
@@ -101,12 +102,12 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
$connection = $gozer->getConnection();
|
||||
|
||||
$tables = $gozer->getTables($connection);
|
||||
$this->assertTrue(in_array('gozerTest__users', $tables, false));
|
||||
self::assertContains('gozerTest__users', $tables);
|
||||
|
||||
$gozer->setDatabasePrefix('gozerTest__');
|
||||
$filteredTables = $gozer->getFilteredTables($tables);
|
||||
$this->assertTrue(is_a($filteredTables, \Illuminate\Support\Collection::class));
|
||||
$this->assertTrue(in_array('gozerTest__users', $filteredTables->toArray(), false));
|
||||
self::assertTrue(is_a($filteredTables, \Illuminate\Support\Collection::class));
|
||||
self::assertContains('gozerTest__users', $filteredTables->toArray());
|
||||
}
|
||||
|
||||
public function test_gozer_table_filtering_works()
|
||||
@@ -123,9 +124,9 @@ class GozerTest extends \Orchestra\Testbench\TestCase
|
||||
$filtered = $gozer->getFilteredTables($tables);
|
||||
$array = $filtered->toArray();
|
||||
|
||||
$this->assertFalse(in_array('this_should_be_filtered', $array, false));
|
||||
$this->assertFalse(in_array('filter_me_too', $array, false));
|
||||
$this->assertTrue(in_array('gozerTest__users', $array, false));
|
||||
$this->assertTrue(in_array('gozerTest__migrations', $array, false));
|
||||
self::assertNotContains('this_should_be_filtered', $array);
|
||||
self::assertNotContains('filter_me_too', $array);
|
||||
self::assertContains('gozerTest__users', $array);
|
||||
self::assertContains('gozerTest__migrations', $array);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,28 @@
|
||||
<?php
|
||||
namespace Superhelio\Commands;
|
||||
|
||||
namespace Superhelio\Commands\Tests;
|
||||
|
||||
use Superhelio\Commands\Commands\Reload;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ReloadTest extends \PHPUnit_Framework_TestCase
|
||||
class ReloadTest extends \Orchestra\Testbench\TestCase
|
||||
{
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Superhelio\Commands\Tests\Stubs;
|
||||
|
||||
class ServiceProvider extends \Illuminate\Support\ServiceProvider
|
||||
|
||||
Reference in New Issue
Block a user