21 Commits

Author SHA1 Message Date
Ismo Vuorinen
61ac97155c feat: update dependencies, add linting, fix codebase, cleanup (#11)
* chore(deps): update dependencies

* feat(tests): add matrix testing, problem matcher

* feat(lint): add php-cs-fixer, fix codebase
2024-11-08 18:40:40 +02:00
dfd2dc0d8a Merge pull request #8 from superhelio/dependabot/composer/laravel/framework-8.83.27 2023-02-02 08:59:49 +02:00
dependabot[bot]
b35379840e Bump laravel/framework from 8.40.0 to 8.83.27
Bumps [laravel/framework](https://github.com/laravel/framework) from 8.40.0 to 8.83.27.
- [Release notes](https://github.com/laravel/framework/releases)
- [Changelog](https://github.com/laravel/framework/blob/9.x/CHANGELOG.md)
- [Commits](https://github.com/laravel/framework/compare/v8.40.0...v8.83.27)

---
updated-dependencies:
- dependency-name: laravel/framework
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-02 06:58:27 +00:00
cf40294ccc Merge pull request #7 from superhelio/dependabot/composer/symfony/http-kernel-5.4.20 2023-02-02 08:58:01 +02:00
dependabot[bot]
15e48db012 Bump symfony/http-kernel from 5.2.6 to 5.4.20
Bumps [symfony/http-kernel](https://github.com/symfony/http-kernel) from 5.2.6 to 5.4.20.
- [Release notes](https://github.com/symfony/http-kernel/releases)
- [Changelog](https://github.com/symfony/http-kernel/blob/6.2/CHANGELOG.md)
- [Commits](https://github.com/symfony/http-kernel/compare/v5.2.6...v5.4.20)

---
updated-dependencies:
- dependency-name: symfony/http-kernel
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-01 22:19:10 +00:00
837c27e126 Merge pull request #6 from superhelio/actions-phpunit
Github Actions: PHPUnit
2021-08-02 10:54:26 +03:00
9a29937b1b added xdebug and mbstring 2021-06-29 13:14:59 +03:00
ee0ea99680 Create phpunit.yml 2021-06-29 13:08:50 +03:00
e1f7575dd7 Merge pull request #5 from superhelio/dependabot/composer/league/flysystem-1.1.4
Bump league/flysystem from 1.1.3 to 1.1.4
2021-06-29 13:00:33 +03:00
dependabot[bot]
d42dc0e4b5 Bump league/flysystem from 1.1.3 to 1.1.4
Bumps [league/flysystem](https://github.com/thephpleague/flysystem) from 1.1.3 to 1.1.4.
- [Release notes](https://github.com/thephpleague/flysystem/releases)
- [Changelog](https://github.com/thephpleague/flysystem/blob/2.x/CHANGELOG.md)
- [Commits](https://github.com/thephpleague/flysystem/compare/1.1.3...1.1.4)

---
updated-dependencies:
- dependency-name: league/flysystem
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-29 05:24:23 +00:00
ded480fd29 Merge pull request #4 from superhelio/dependabot/composer/laravel/framework-8.40.0
Bump laravel/framework from 8.26.1 to 8.40.0
2021-04-30 10:24:12 +03:00
dependabot[bot]
c987038e44 Bump laravel/framework from 8.26.1 to 8.40.0
Bumps [laravel/framework](https://github.com/laravel/framework) from 8.26.1 to 8.40.0.
- [Release notes](https://github.com/laravel/framework/releases)
- [Changelog](https://github.com/laravel/framework/blob/8.x/CHANGELOG-8.x.md)
- [Commits](https://github.com/laravel/framework/compare/v8.26.1...v8.40.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-29 22:34:20 +00:00
528a4f06a3 Update auto-approve.yml 2021-02-18 19:16:54 +02:00
2cd7420fe3 Auto Approve Dependabot 2021-02-18 16:54:57 +02:00
8a9ad3faf7 Merge pull request #3 from superhelio/dependabot/composer/laravel/framework-8.26.1
Bump laravel/framework from 8.23.1 to 8.26.1
2021-02-02 19:36:38 +02:00
dependabot[bot]
c1e58d03a7 Bump laravel/framework from 8.23.1 to 8.26.1
Bumps [laravel/framework](https://github.com/laravel/framework) from 8.23.1 to 8.26.1.
- [Release notes](https://github.com/laravel/framework/releases)
- [Changelog](https://github.com/laravel/framework/blob/8.x/CHANGELOG-8.x.md)
- [Commits](https://github.com/laravel/framework/compare/v8.23.1...v8.26.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-02 16:28:30 +00:00
2d0eeef248 Merge pull request #2 from superhelio/feat/maintenance-2021
Updated requirements
2021-01-21 12:33:36 +02:00
Ismo Vuorinen
c0ba631f42 PSR2 fixes 2021-01-20 14:18:42 +02:00
Ismo Vuorinen
dd33dcbb61 Updated requirements 2021-01-20 11:44:34 +02:00
7985d7c777 Merge pull request #1 from superhelio/dependabot/composer/symfony/http-foundation-3.4.36
Bump symfony/http-foundation from 3.3.10 to 3.4.36
2019-12-10 11:07:10 +02:00
dependabot[bot]
8d14242960 Bump symfony/http-foundation from 3.3.10 to 3.4.36
Bumps [symfony/http-foundation](https://github.com/symfony/http-foundation) from 3.3.10 to 3.4.36.
- [Release notes](https://github.com/symfony/http-foundation/releases)
- [Changelog](https://github.com/symfony/http-foundation/blob/master/CHANGELOG.md)
- [Commits](https://github.com/symfony/http-foundation/compare/v3.3.10...v3.4.36)

Signed-off-by: dependabot[bot] <support@github.com>
2019-12-04 14:24:47 +00:00
19 changed files with 215 additions and 3611 deletions

16
.editorconfig Normal file
View File

@@ -0,0 +1,16 @@
# EditorConfig is awesome: https://editorconfig.org
# top-most EditorConfig file
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
max_line_length = 100
[*.yml]
indent_size = 2

12
.github/workflows/auto-approve.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: Auto Approve Dependabot
on: pull_request_target
jobs:
auto-approve:
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v2.0.0
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

45
.github/workflows/phpunit.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: PHPUnit
on: [push]
jobs:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
php_version:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
tools: composer, phpunit
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php_version }}-${{ hashFiles('**/composer.json') }}
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Configure matchers
uses: mheap/phpunit-matcher-action@v1
- name: Run tests
run: composer test-ci

1
.gitignore vendored
View File

@@ -1 +1,2 @@
vendor vendor
composer.lock

15
.php-cs-fixer.dist.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
$finder = (new PhpCsFixer\Finder())
->in(__DIR__);
return (new PhpCsFixer\Config())
->setRules([
'@PhpCsFixer' => true,
'@PHP74Migration' => true,
'@PSR12' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder($finder)
;

View File

@@ -1,20 +0,0 @@
language: php
php:
- 7.0
- 7.1
- nightly
matrix:
allow_failures:
- php: nightly
fast_finish: true
cache:
directories:
- $HOME/.composer/cache/files
before_script:
- phpenv global "$TRAVIS_PHP_VERSION"
- composer config extra.platform.php $TRAVIS_PHP_VERSION
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

View File

@@ -1,16 +1,13 @@
# 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)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
[![Quality Score][ico-code-quality]][link-code-quality]
[![Total Downloads][ico-downloads]][link-downloads] [![Total Downloads][ico-downloads]][link-downloads]
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 +24,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');
} }
} }
@@ -35,10 +32,10 @@ public function register()
## Usage ## Usage
- *superhelio:gozer* - _superhelio:gozer_
- Force delete database tables that have your table prefix - Force delete database tables that have your table prefix
- `php artisan superhelio:gozer` - `php artisan superhelio:gozer`
- *superhelio:reload* - _superhelio:reload_
- Reset database, migrate and seed - Reset database, migrate and seed
- `php artisan superhelio:reload` - `php artisan superhelio:reload`
@@ -67,15 +64,8 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
[ico-version]: https://img.shields.io/packagist/v/superhelio/commands.svg?style=flat-square [ico-version]: https://img.shields.io/packagist/v/superhelio/commands.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/superhelio/commands/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/superhelio/commands.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/superhelio/commands.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/superhelio/commands.svg?style=flat-square [ico-downloads]: https://img.shields.io/packagist/dt/superhelio/commands.svg?style=flat-square
[link-packagist]: https://packagist.org/packages/superhelio/commands [link-packagist]: https://packagist.org/packages/superhelio/commands
[link-travis]: https://travis-ci.org/superhelio/commands
[link-scrutinizer]: https://scrutinizer-ci.com/g/superhelio/commands/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/superhelio/commands
[link-downloads]: https://packagist.org/packages/superhelio/commands [link-downloads]: https://packagist.org/packages/superhelio/commands
[link-author]: https://github.com/superhelio [link-author]: https://github.com/superhelio
[link-contributors]: https://github.com/superhelio/commands/graphs/contributors [link-contributors]: https://github.com/superhelio/commands/graphs/contributors

View File

@@ -17,13 +17,15 @@
} }
], ],
"require": { "require": {
"php" : ">=7.0", "php": "^7.4|^8",
"illuminate/support": "^5.3|^5.4|^5.5", "illuminate/support": "^5.3|^6|^7|^8|^9|^10|^11",
"doctrine/dbal": "^2.5|^2.6" "doctrine/dbal": "^2.5|^2.6|^3"
}, },
"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|^7|^8",
"friendsofphp/php-cs-fixer": "^3.9"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@@ -36,7 +38,9 @@
} }
}, },
"scripts": { "scripts": {
"test": "phpunit" "lint": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --diff --allow-risky=yes",
"test": "phpunit",
"test-ci": "phpunit --teamcity"
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {

3483
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">

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
{ {
@@ -75,16 +76,14 @@ class Gozer extends Command
*/ */
$tables = $this->getFilteredTables($tables); $tables = $this->getFilteredTables($tables);
/** // Check that we got at least one table, bail out if not
* Check that we got at least one table, bail out if not
*/
if ($tables->count() < 1) { if ($tables->count() < 1) {
$this->info('There are no tables, only Zuul.'); $this->info('There are no tables, only Zuul.');
return true; return true;
} }
/** /*
* Bid your farewells to these tables. * Bid your farewells to these tables.
* Last look and confirmation. * Last look and confirmation.
*/ */
@@ -94,27 +93,22 @@ class Gozer extends Command
)); ));
$this->line(''); $this->line('');
/** // Last confirmation before dropping tables
* Last confirmation before dropping tables
*/
if ($this->confirm('Really delete those tables?')) { if ($this->confirm('Really delete those tables?')) {
/** Fancy pants progress bar to see your tables get destroyed */ /** Fancy pants progress bar to see your tables get destroyed */
$bar = $this->output->createProgressBar($tables->count()); $bar = $this->output->createProgressBar($tables->count());
Schema::disableForeignKeyConstraints(); Schema::disableForeignKeyConstraints();
$tables->each(function ($table) use ($bar, $connection) { $tables->each(function ($table) use ($bar, $connection) {
// Drop the table
/** Drop the table */
$connection->dropTable($table); $connection->dropTable($table);
/** Advance our progress bar */ // Advance our progress bar
$bar->advance(); $bar->advance();
}); });
Schema::enableForeignKeyConstraints(); Schema::enableForeignKeyConstraints();
/** Progress bar is now finished */ // Progress bar is now finished
$bar->finish(); $bar->finish();
} }
@@ -133,20 +127,16 @@ class Gozer extends Command
public function getConnection() public function getConnection()
{ {
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;
} }
/** /**
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $connection
*
* @return array|bool * @return array|bool
*/ */
public function getTables(\Doctrine\DBAL\Schema\AbstractSchemaManager $connection) public function getTables(\Doctrine\DBAL\Schema\AbstractSchemaManager $connection)
@@ -165,11 +155,11 @@ class Gozer extends Command
public function getDatabasePrefix() public function getDatabasePrefix()
{ {
return trim(DB::getTablePrefix()); return trim(DB::connection()->getTablePrefix());
} }
/** /**
* This is mainly for testing purposes * This is mainly for testing purposes.
* *
* @param string $prefix * @param string $prefix
*/ */
@@ -179,7 +169,7 @@ class Gozer extends Command
} }
/** /**
* @param array $tables * @param array|\Illuminate\Support\Collection $tables
* *
* @return \Illuminate\Support\Collection * @return \Illuminate\Support\Collection
*/ */
@@ -188,7 +178,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

@@ -33,7 +33,7 @@ class Reload extends Command
[ [
'--no-interaction' => true, '--no-interaction' => true,
'--env' => 'development', '--env' => 'development',
'--verbose' => 3 '--verbose' => 3,
] ]
); );
$this->call( $this->call(
@@ -42,11 +42,13 @@ class Reload extends Command
'--seed' => true, '--seed' => true,
'--no-interaction' => true, '--no-interaction' => true,
'--env' => 'development', '--env' => 'development',
'--verbose' => 3 '--verbose' => 3,
] ]
); );
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

@@ -5,9 +5,8 @@ namespace Superhelio\Commands;
use Illuminate\Support\ServiceProvider as BaseServiceProvider; use Illuminate\Support\ServiceProvider as BaseServiceProvider;
/** /**
* Class PackageServiceProvider * Class PackageServiceProvider.
* *
* @package Superhelio\Commands
* @see http://laravel.com/docs/master/packages#service-providers * @see http://laravel.com/docs/master/packages#service-providers
* @see http://laravel.com/docs/master/providers * @see http://laravel.com/docs/master/providers
*/ */
@@ -17,6 +16,7 @@ class ServiceProvider extends BaseServiceProvider
* Indicates if loading of the provider is deferred. * Indicates if loading of the provider is deferred.
* *
* @see http://laravel.com/docs/master/providers#deferred-providers * @see http://laravel.com/docs/master/providers#deferred-providers
*
* @var bool * @var bool
*/ */
protected $defer = false; protected $defer = false;
@@ -25,7 +25,6 @@ class ServiceProvider extends BaseServiceProvider
* Register the service provider. * Register the service provider.
* *
* @see http://laravel.com/docs/master/providers#the-register-method * @see http://laravel.com/docs/master/providers#the-register-method
* @return void
*/ */
public function register() public function register()
{ {
@@ -36,7 +35,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 +43,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,17 +1,22 @@
<?php <?php
namespace Superhelio\Commands;
namespace Superhelio\Commands\Tests;
use ReflectionClass; use ReflectionClass;
use Superhelio\Commands\Commands\Gozer; use Superhelio\Commands\Commands\Gozer;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
/**
* @internal
* @coversNothing
*/
class GozerTest extends \Orchestra\Testbench\TestCase 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']);
@@ -21,8 +26,6 @@ class GozerTest extends \Orchestra\Testbench\TestCase
* Define environment setup. * Define environment setup.
* *
* @param \Illuminate\Foundation\Application $app * @param \Illuminate\Foundation\Application $app
*
* @return void
*/ */
protected function getEnvironmentSetUp($app) protected function getEnvironmentSetUp($app)
{ {
@@ -49,83 +52,83 @@ class GozerTest extends \Orchestra\Testbench\TestCase
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,
]; ];
} }
public function test_database_is_there_and_functions() public function testDatabaseIsThereAndFunctions()
{ {
DB::table('users')->insert([ DB::table('users')->insert([
'name' => 'User name', 'name' => 'User name',
'email' => 'hello@gozer.dev', 'email' => 'hello@gozer.dev',
'password' => bcrypt('123') 'password' => bcrypt('123'),
]); ]);
$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 testDbalIsInstalled()
{ {
$this->assertTrue(class_exists('\\Doctrine\\DBAL\\Schema\\Schema')); self::assertTrue(class_exists('\\Doctrine\\DBAL\\Schema\\Schema'));
} }
public function test_gozer_is_installed() public function testGozerIsInstalled()
{ {
$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 testGozerHasRequiredMethodsAndProperties()
{ {
$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 testGozerFindsDatabasePrefix()
{ {
$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 testGozerFindsUsersTable()
{ {
$gozer = new Gozer(); $gozer = new Gozer();
$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 testGozerTableFilteringWorks()
{ {
$gozer = new Gozer(); $gozer = new Gozer();
$tables = array( $tables = [
'gozerTest__users', 'gozerTest__users',
'gozerTest__migrations', 'gozerTest__migrations',
'this_should_be_filtered', 'this_should_be_filtered',
'filter_me_too' 'filter_me_too',
); ];
$gozer->setDatabasePrefix('gozerTest__'); $gozer->setDatabasePrefix('gozerTest__');
$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;
use Superhelio\Commands\Commands\Reload; namespace Superhelio\Commands\Tests;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ReloadTest extends \PHPUnit_Framework_TestCase /**
* @internal
* @coversNothing
*/
class ReloadTest extends \Orchestra\Testbench\TestCase
{ {
public function testReloadTest() public function testReloadTest()
{ {
$this->assertTrue(true); self::assertTrue(true);
}
public function testReloadIsInstalled()
{
self::assertTrue(class_exists('\\Superhelio\\Commands\\Commands\\Reload'));
}
public function testReloadHasRequiredMethodsAndProperties()
{
$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

View File

@@ -8,8 +8,6 @@ class CreateUsersTable extends Migration
{ {
/** /**
* Run the migrations. * Run the migrations.
*
* @return void
*/ */
public function up() public function up()
{ {
@@ -25,8 +23,6 @@ class CreateUsersTable extends Migration
/** /**
* Reverse the migrations. * Reverse the migrations.
*
* @return void
*/ */
public function down() public function down()
{ {