Initial Commit

master
Muhep Atasoy 2019-12-10 21:55:40 +03:00
commit 5cb8e16191
33 changed files with 5036 additions and 0 deletions

16
.editorconfig Normal file
View File

@ -0,0 +1,16 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.yml]
indent_style = space
indent_size = 2

7
.gitattributes vendored Normal file
View File

@ -0,0 +1,7 @@
* text=auto
.travis.yml export-ignore
.styleci.yml export-ignore
.scrutinizer.yml export-ignore
BACKERS.md export-ignore
CONTRIBUTING.md export-ignore
CHANGELOG.md export-ignore

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/vendor
/.idea
/.vscode
/.vagrant
/.github

37
README.md Normal file
View File

@ -0,0 +1,37 @@
<p align="center">
<img title="Laravel Zero" height="100" src="https://raw.githubusercontent.com/laravel-zero/docs/master/images/logo/laravel-zero-readme.png" />
</p>
<p align="center">
<a href="https://travis-ci.org/laravel-zero/framework"><img src="https://img.shields.io/travis/laravel-zero/framework/stable.svg" alt="Build Status"></img></a>
<a href="https://scrutinizer-ci.com/g/laravel-zero/framework"><img src="https://img.shields.io/scrutinizer/g/laravel-zero/framework.svg" alt="Quality Score"></img></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://poser.pugx.org/laravel-zero/framework/license.svg" alt="License"></a>
</p>
<h4> <center>This is a <bold>community project</bold> and not an official Laravel one </center></h4>
Laravel Zero was created by, and is maintained by [Nuno Maduro](https://github.com/nunomaduro), and is a micro-framework that provides an elegant starting point for your console application. It is an **unofficial** and customized version of Laravel optimized for building command-line applications.
- Built on top of the [Laravel](https://laravel.com) components.
- Optional installation of Laravel [Eloquent](https://laravel-zero.com/docs/database/), Laravel [Logging](https://laravel-zero.com/docs/logging/) and many others.
- Supports interactive [menus](https://laravel-zero.com/docs/build-interactive-menus/) and [desktop notifications](https://laravel-zero.com/docs/send-desktop-notifications/) on Linux, Windows & MacOS.
- Ships with a [Scheduler](https://laravel-zero.com/docs/task-scheduling/) and a [Standalone Compiler](https://laravel-zero.com/docs/build-a-standalone-application/).
- Integration with [Collision](https://github.com/nunomaduro/collision) - Beautiful error reporting
------
## Documentation
For full documentation, visit [laravel-zero.com](https://laravel-zero.com/).
## Support the development
**Do you like this project? Support it by donating**
- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=66BYDWAT92N6L)
- Patreon: [Donate](https://www.patreon.com/nunomaduro)
## License
Laravel Zero is an open-source software licensed under the [MIT license](https://github.com/laravel-zero/laravel-zero/blob/stable/LICENSE.md).

0
app/Commands/.gitkeep Normal file
View File

View File

@ -0,0 +1,62 @@
<?php
namespace App\Commands;
use App\Constants\BuilderMode;
use App\Utils\BackupManager;
use App\Utils\Builders\ContainerBuilder;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
class ContainerBackupCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'backup:container {containers*} {--backupFolder=}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Backup Docker Container';
/**
* Execute the console command.
*
* @return mixed
* @throws \Throwable
*/
public function handle()
{
$backupFolder = $this->option('backupFolder');
$containers = $this->argument('containers');
$bm = new BackupManager();
foreach ($containers as $container) {
$this->line("<fg=blue>|-> Backing up {$container}...</>");
$builder = new ContainerBuilder();
$builder->setBackupFolder($backupFolder)->setContainerName($container);
$bm->setBuilder($builder)->execute();
if ($bm->getShell()->getReturnValue() == 0) {
$this->line("<fg=green> |-> {$container} successfully backed up.</>");
} else {
$this->line("<fg=red> |-> {$container} could not be backed up.</>");
}
}
return;
}
/**
* Define the command's schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function schedule(Schedule $schedule): void
{
// $schedule->command(static::class)->everyMinute();
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace App\Commands;
use App\Utils\BackupManager;
use App\Utils\Builders\DataBuilder;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use Throwable;
class DataBackupCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'backup:data {--dataFolder=} {--backupFolder=}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Backup containers data folder.';
/**
* Execute the console command.
*
* @return mixed
* @throws Throwable
*/
public function handle()
{
$backupFolder = $this->option('backupFolder');
$dataFolder = $this->option('dataFolder');
$bm = new BackupManager();
$this->line("<fg=blue>|-> Backing up data folder...</>");
$builder = new DataBuilder();
$builder->setDataFolder($dataFolder)->setBackupFolder($backupFolder);
$bm->setBuilder($builder)->execute();
if ($bm->getShell()->getReturnValue() == 0) {
$this->line("<fg=green> |-> Data folder successfully backed up.</>");
} else {
$this->line("<fg=red> |-> Data folder could not be backed up.</>");
}
return;
}
/**
* Define the command's schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function schedule(Schedule $schedule): void
{
// $schedule->command(static::class)->everyMinute();
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
class InspiringCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'inspiring {name=Artisan}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Display an inspiring quote';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('Simplicity is the ultimate sophistication.');
}
/**
* Define the command's schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function schedule(Schedule $schedule)
{
// $schedule->command(static::class)->everyMinute();
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace App\Commands;
use App\Utils\BackupManager;
use App\Utils\Builders\DatabaseBuilder;
use App\Utils\Credential;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
class MysqlBackupCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'backup:mysql {--container=} {--user=} {--password=} {--backupFolder=}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Backup mysql databases.';
/**
* Execute the console command.
*
* @return mixed
* @throws \Throwable
*/
public function handle()
{
$container = $this->option('container');
$user = $this->option('user');
$password = $this->option('password');
$backupFolder = $this->option('backupFolder');
$bm = new BackupManager();
$this->line("<fg=blue>|-> Backing up mysql databases...</>");
$credentials = new Credential();
$credentials->setUsername($user);
$credentials->setPassword($password);
$builder = new DatabaseBuilder();
$builder->setCredential($credentials);
$builder->setBackupFolder($backupFolder)->setContainerName($container);
$output = $bm->setBuilder($builder)->execute();
if ($bm->getShell()->getReturnValue() == 0) {
$this->line("<fg=green> |-> Mysql databases successfully backed up.</>");
} else {
$this->line("<fg=red> |-> Mysql databases could not be backed up.</>");
}
return;
}
/**
* Define the command's schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function schedule(Schedule $schedule): void
{
// $schedule->command(static::class)->everyMinute();
}
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Constants;
class BuilderMode
{
const CONTAINER = 0;
const DATA = 1;
const MYSQL = 2;
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Exceptions;
use Exception;
class BackupFolderNotFoundException extends Exception
{
}

View File

@ -0,0 +1,10 @@
<?php
namespace App\Exceptions;
use Exception;
class DataFolderNotFoundException extends Exception
{
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Exceptions;
use Exception;
class ExportFolderNotFoundException extends Exception
{
protected $message = "Export folder is not exist!";
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

165
app/Utils/BackupManager.php Normal file
View File

@ -0,0 +1,165 @@
<?php
namespace App\Utils;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
use AdamBrett\ShellWrapper\Runners\Exec;
use App\Exceptions\BackupFolderNotFoundException;
use App\Exceptions\ExportFolderNotFoundException;
use Throwable;
class BackupManager
{
private $exportFolder;
private $dataFolder;
private $backupFolder;
private $shell;
private $params;
private $builder;
private $containerName;
public function __construct()
{
$this->shell = new Exec();
$this->builder = new CommandBuilder("");
$this->backupFolder = ".";
$this->exportFolder = ".";
}
/**
* @param mixed $backupFolder
* @return BackupManager
* @throws Throwable
*/
public function setBackupFolder($backupFolder): BackupManager
{
throw_if(!file_exists($backupFolder), new BackupFolderNotFoundException('Backup folder not exist!'));
$this->backupFolder = $backupFolder;
return $this;
}
/**
* @param mixed $dataFolder
* @return BackupManager
* @throws Throwable
*/
public function setDataFolder($dataFolder): BackupManager
{
throw_if(!file_exists($dataFolder), new BackupFolderNotFoundException('Data folder not exist!'));
$this->dataFolder = $dataFolder;
return $this;
}
/**
* @param mixed $exportFolder
* @return BackupManager
* @throws Throwable
*/
public function setExportFolder($exportFolder): BackupManager
{
throw_if(!file_exists($exportFolder), new ExportFolderNotFoundException('Export folder not exist!'));
$this->exportFolder = $exportFolder;
return $this;
}
/**
* @param $param
* @return BackupManager
*/
public function addParams(array $params): BackupManager
{
$this->params = $params;
return $this;
}
/**
* @param mixed $containerName
* @return BackupManager
*/
public function setContainerName($containerName): BackupManager
{
$this->containerName = $containerName;
return $this;
}
/**
* @return mixed
*/
public function getParams()
{
return $this->params;
}
/**
* @return Exec
*/
public function getShell(): Exec
{
return $this->shell;
}
/**
* @return mixed
*/
public function getBackupFolder()
{
return $this->backupFolder;
}
/**
* @return mixed
*/
public function getDataFolder()
{
return $this->dataFolder;
}
/**
* @return mixed
*/
public function getExportFolder()
{
return $this->exportFolder;
}
/**
* @return mixed
*/
public function getContainerName()
{
return $this->containerName;
}
/*
* @param int $mode
* @return BackupManager
*/
/*public function builder(int $mode): BackupManager
{
switch ($mode) {
case BuilderMode::CONTAINER:
$this->builder = new Builder("docker export {$this->containerName} -o {$this->backupFolder}/{$this->containerName}.tar.gz");
break;
case BuilderMode::DATA:
$this->builder = new Builder("tar -zcf");
break;
case BuilderMode::MYSQL:
$this->builder = new Builder("docker exec");
break;
default:
$this->builder = new Builder("");
}
return $this;
}*/
public function setBuilder(Builder $builder): BackupManager
{
$this->builder = $builder->builder();
return $this;
}
public function execute()
{
return $this->shell->run($this->builder);
}
}

56
app/Utils/Builder.php Normal file
View File

@ -0,0 +1,56 @@
<?php
namespace App\Utils;
use \AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
use App\Exceptions\BackupFolderNotFoundException;
use Throwable;
abstract class Builder
{
private $backupFolder;
private $containerName;
/**
* @param $backupFolder
* @return Builder
* @throws Throwable
*/
public function setBackupFolder($backupFolder): Builder
{
throw_if(!file_exists($backupFolder), new BackupFolderNotFoundException('Backup folder not exist!'));
$this->backupFolder = $backupFolder;
return $this;
}
/**
* @return string
*/
public function getBackupFolder(): string
{
return $this->backupFolder;
}
/**
* @param $containerName
* @return Builder
*/
public function setContainerName($containerName): Builder
{
$this->containerName = $containerName;
return $this;
}
/**
* @return string
*/
public function getContainerName(): string
{
return $this->containerName;
}
/**
* @return CommandBuilder
*/
abstract public function builder(): CommandBuilder;
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Utils\Builders;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
use App\Utils\Builder;
class ContainerBuilder extends Builder
{
public function builder(): CommandBuilder
{
return new CommandBuilder("docker export {$this->getContainerName()} -o {$this->getBackupFolder()}/{$this->getContainerName()}.tar.gz");
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Utils\Builders;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
use App\Utils\Builder;
use App\Utils\Traits\Auth;
class DataBuilder extends Builder
{
private $dataFolder;
/**
* @param mixed $dataFolder
* @return Builder
*/
public function setDataFolder($dataFolder): Builder
{
$this->dataFolder = $dataFolder;
return $this;
}
/**
* @return string
*/
public function getDataFolder()
{
return $this->dataFolder;
}
public function builder(): CommandBuilder
{
return new CommandBuilder("tar -zcf {$this->getBackupFolder()}/data.tar.gz {$this->getDataFolder()}");
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\Utils\Builders;
use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
use App\Utils\Builder;
use App\Utils\Traits\Auth;
class DatabaseBuilder extends Builder
{
use Auth;
/**
* @return CommandBuilder
*/
public function builder(): CommandBuilder
{
$credential = $this->getCredential();
return new CommandBuilder("docker exec {$this->getContainerName()} /usr/bin/mysqldump " .
"{$this->getUsernameArg()}{$credential->getUsername()} {$this->getPasswordArg()}{$credential->getPassword()} --all-databases > " .
"{$this->getBackupFolder()}/backup.sql");
}
}

45
app/Utils/Credential.php Normal file
View File

@ -0,0 +1,45 @@
<?php
namespace App\Utils;
class Credential
{
private $username;
private $password;
/**
* @param string $username
* @return Credential
*/
public function setUsername(string $username): Credential
{
$this->username = $username;
return $this;
}
/**
* @return mixed
*/
public function getUsername()
{
return $this->username;
}
/**
* @param string $password
* @return Credential
*/
public function setPassword(string $password): Credential
{
$this->password = $password;
return $this;
}
/**
* @return mixed
*/
public function getPassword()
{
return $this->password;
}
}

66
app/Utils/Traits/Auth.php Normal file
View File

@ -0,0 +1,66 @@
<?php
namespace App\Utils\Traits;
use App\Utils\Credential;
trait Auth
{
private $credential;
private $usernameArg;
private $passwordArg;
public function __construct()
{
$this->usernameArg = "--user=";
$this->passwordArg = "--password=";
}
/**
* @param Credential $credential
*/
public function setCredential(Credential $credential): void
{
$this->credential = $credential;
}
/**
* @return Credential
*/
public function getCredential(): Credential
{
return $this->credential;
}
/**
* @param string $usernameArg
*/
public function setUsernameArg(string $usernameArg = "--user="): void
{
$this->usernameArg = $usernameArg;
}
/**
* @return string
*/
public function getUsernameArg(): string
{
return $this->usernameArg;
}
/**
* @param string $passwordArg
*/
public function setPasswordArg(string $passwordArg = "--password="): void
{
$this->passwordArg = $passwordArg;
}
/**
* @return string
*/
public function getPasswordArg(): string
{
return $this->passwordArg;
}
}

53
backupper Normal file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
$autoloader = require file_exists(__DIR__.'/vendor/autoload.php') ? __DIR__.'/vendor/autoload.php' : __DIR__.'/../../autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/
$kernel->terminate($input, $status);
exit($status);

50
bootstrap/app.php Normal file
View File

@ -0,0 +1,50 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new LaravelZero\Framework\Application(
dirname(__DIR__)
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
LaravelZero\Framework\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
Illuminate\Foundation\Exceptions\Handler::class
);
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;

18
box.json Normal file
View File

@ -0,0 +1,18 @@
{
"chmod": "0755",
"directories": [
"app",
"bootstrap",
"config",
"vendor"
],
"files": [
"composer.json"
],
"exclude-composer-files": false,
"compression": "GZ",
"compactors": [
"KevinGH\\Box\\Compactor\\Php",
"KevinGH\\Box\\Compactor\\Json"
]
}

50
composer.json Normal file
View File

@ -0,0 +1,50 @@
{
"name": "laravel-zero/laravel-zero",
"description": "The Laravel Zero Framework.",
"keywords": ["framework", "laravel", "laravel zero", "console", "cli"],
"homepage": "https://laravel-zero.com",
"type": "project",
"license": "MIT",
"support": {
"issues": "https://github.com/laravel-zero/laravel-zero/issues",
"source": "https://github.com/laravel-zero/laravel-zero"
},
"authors": [
{
"name": "Nuno Maduro",
"email": "enunomaduro@gmail.com"
}
],
"require": {
"php": "^7.2",
"adambrett/shell-wrapper": "^0.8.0",
"laravel-zero/framework": "^6.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"scripts": {
"post-create-project-cmd": [
"@php application app:rename"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"bin": ["backupper"]
}

3856
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

59
config/app.php Normal file
View File

@ -0,0 +1,59 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => 'Backupper',
/*
|--------------------------------------------------------------------------
| Application Version
|--------------------------------------------------------------------------
|
| This value determines the "version" your application is currently running
| in. You may want to follow the "Semantic Versioning" - Given a version
| number MAJOR.MINOR.PATCH when an update happens: https://semver.org.
|
*/
'version' => app('git.version'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Should be true in production.
|
*/
'production' => false,
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
App\Providers\AppServiceProvider::class,
],
];

80
config/commands.php Normal file
View File

@ -0,0 +1,80 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Command
|--------------------------------------------------------------------------
|
| Laravel Zero will always run the command specified below when no command name is
| provided. Consider update the default command for single command applications.
| You cannot pass arguments to the default command because they are ignored.
|
*/
'default' => NunoMaduro\LaravelConsoleSummary\SummaryCommand::class,
/*
|--------------------------------------------------------------------------
| Commands Paths
|--------------------------------------------------------------------------
|
| This value determines the "paths" that should be loaded by the console's
| kernel. Foreach "path" present on the array provided below the kernel
| will extract all "Illuminate\Console\Command" based class commands.
|
*/
'paths' => [app_path('Commands')],
/*
|--------------------------------------------------------------------------
| Added Commands
|--------------------------------------------------------------------------
|
| You may want to include a single command class without having to load an
| entire folder. Here you can specify which commands should be added to
| your list of commands. The console's kernel will try to load them.
|
*/
'add' => [
// ..
],
/*
|--------------------------------------------------------------------------
| Hidden Commands
|--------------------------------------------------------------------------
|
| Your application commands will always be visible on the application list
| of commands. But you can still make them "hidden" specifying an array
| of commands below. All "hidden" commands can still be run/executed.
|
*/
'hidden' => [
NunoMaduro\LaravelConsoleSummary\SummaryCommand::class,
Symfony\Component\Console\Command\HelpCommand::class,
Illuminate\Console\Scheduling\ScheduleRunCommand::class,
Illuminate\Console\Scheduling\ScheduleFinishCommand::class,
Illuminate\Foundation\Console\VendorPublishCommand::class,
],
/*
|--------------------------------------------------------------------------
| Removed Commands
|--------------------------------------------------------------------------
|
| Do you have a service provider that loads a list of commands that
| you don't need? No problem. Laravel Zero allows you to specify
| below a list of commands that you don't to see in your app.
|
*/
'remove' => [
// ..
],
];

27
phpunit.xml.dist Normal file
View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="NunoMaduro\Collision\Adapters\Phpunit\Listener"/>
</listeners>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -0,0 +1,22 @@
<?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace Tests\Feature;
use Tests\TestCase;
class InspiringCommandTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testInspiringCommand()
{
$this->artisan('inspiring')
->expectsOutput('Simplicity is the ultimate sophistication.')
->assertExitCode(0);
}
}

10
tests/TestCase.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace Tests;
use LaravelZero\Framework\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
}

View File

@ -0,0 +1,18 @@
<?php
namespace Tests\Unit;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$this->assertTrue(true);
}
}