mirror of
https://github.com/anikeen-com/print-cli.git
synced 2026-03-13 13:46:07 +00:00
Initial commit
This commit is contained in:
15
.editorconfig
Normal file
15
.editorconfig
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
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_size = 2
|
||||||
6
.gitattributes
vendored
Normal file
6
.gitattributes
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
/.github export-ignore
|
||||||
|
.scrutinizer.yml export-ignore
|
||||||
|
BACKERS.md export-ignore
|
||||||
|
CONTRIBUTING.md export-ignore
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/vendor
|
||||||
|
/.idea
|
||||||
|
/.vscode
|
||||||
|
/.vagrant
|
||||||
|
.phpunit.result.cache
|
||||||
34
README.md
Normal file
34
README.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<p align="center">
|
||||||
|
<img title="Laravel Zero" height="100" src="https://raw.githubusercontent.com/laravel-zero/docs/master/images/logo/laravel-zero-readme.png" alt="Laravel Zero Logo" />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/laravel-zero/framework/actions"><img src="https://github.com/laravel-zero/laravel-zero/actions/workflows/tests.yml/badge.svg" alt="Build Status" /></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/dt/laravel-zero/framework.svg" alt="Total Downloads" /></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/v/laravel-zero/framework.svg?label=stable" alt="Latest Stable Version" /></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel-zero/framework"><img src="https://img.shields.io/packagist/l/laravel-zero/framework.svg" alt="License" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
Laravel Zero was created by [Nuno Maduro](https://github.com/nunomaduro) and [Owen Voke](https://github.com/owenvoke), 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.
|
||||||
48
app/Commands/InspireCommand.php
Normal file
48
app/Commands/InspireCommand.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use LaravelZero\Framework\Commands\Command;
|
||||||
|
|
||||||
|
use function Termwind\{render};
|
||||||
|
|
||||||
|
class InspireCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The signature of the command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'inspire {name=Artisan}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The description of the command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Display an inspiring quote';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
render(<<<'HTML'
|
||||||
|
<div class="py-1 ml-2">
|
||||||
|
<div class="px-1 bg-blue-300 text-black">Laravel Zero</div>
|
||||||
|
<em class="ml-1">
|
||||||
|
Simplicity is the ultimate sophistication.
|
||||||
|
</em>
|
||||||
|
</div>
|
||||||
|
HTML);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the command's schedule.
|
||||||
|
*/
|
||||||
|
public function schedule(Schedule $schedule): void
|
||||||
|
{
|
||||||
|
// $schedule->command(static::class)->everyMinute();
|
||||||
|
}
|
||||||
|
}
|
||||||
119
app/Commands/ServeCommand.php
Normal file
119
app/Commands/ServeCommand.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Http\Client\RequestException;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use LaravelZero\Framework\Commands\Command;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class ServeCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'serve';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Command description';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
* @throws RequestException
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->info('Starting service...');
|
||||||
|
|
||||||
|
$yaml = $this->getConfiguration();
|
||||||
|
$printerIds = array_map(fn($printer) => $printer['id'], $yaml['printers']);
|
||||||
|
|
||||||
|
$response = Http::patch(sprintf('%s/api/printers/register', $yaml['base_url']), [
|
||||||
|
'printers' => $yaml['printers'],
|
||||||
|
'status' => 'online',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->throw();
|
||||||
|
|
||||||
|
$this->info('Service started!');
|
||||||
|
|
||||||
|
do {
|
||||||
|
$response = Http::get(sprintf('%s/api/printers/jobs', $yaml['base_url']), [
|
||||||
|
'printer_ids' => $printerIds,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
$this->error('Failed to fetch jobs, error: ' . $response->status());
|
||||||
|
sleep(2);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$jobs = $response->json();
|
||||||
|
|
||||||
|
if (empty($jobs)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('Printing jobs...');
|
||||||
|
|
||||||
|
foreach ($jobs as $job) {
|
||||||
|
try {
|
||||||
|
$this->handleJob($job, $yaml);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(2);
|
||||||
|
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getConfiguration(): array
|
||||||
|
{
|
||||||
|
$this->info('Reading configuration...');
|
||||||
|
$yaml = file_get_contents(base_path('print-cli.yml'));
|
||||||
|
return Yaml::parse($yaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RequestException
|
||||||
|
*/
|
||||||
|
private function handleJob(array $job, mixed $yaml): void
|
||||||
|
{
|
||||||
|
if (!empty($job['data']['preview'])) {
|
||||||
|
$this->info(sprintf('Job %s is a preview', $job['id']));
|
||||||
|
$this->markCompleted($job, $yaml);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->markCompleted($job, $yaml);
|
||||||
|
|
||||||
|
$this->info(sprintf('Job %s completed', $job['id']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RequestException
|
||||||
|
*/
|
||||||
|
private function markCompleted(array $job, mixed $yaml): void
|
||||||
|
{
|
||||||
|
$response = Http::patch(sprintf('%s/api/printers/jobs/%s/complete', $yaml['base_url'], $job['id']));
|
||||||
|
$response->throw();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws RequestException
|
||||||
|
*/
|
||||||
|
private function markFailed(array $job, mixed $yaml): void
|
||||||
|
{
|
||||||
|
$response = Http::patch(sprintf('%s/api/printers/jobs/%s/fail', $yaml['base_url'], $job['id']));
|
||||||
|
$response->throw();
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Providers/AppServiceProvider.php
Normal file
24
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
5
bootstrap/app.php
Normal file
5
bootstrap/app.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use LaravelZero\Framework\Application;
|
||||||
|
|
||||||
|
return Application::configure(basePath: dirname(__DIR__))->create();
|
||||||
5
bootstrap/providers.php
Normal file
5
bootstrap/providers.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
];
|
||||||
18
box.json
Normal file
18
box.json
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
52
composer.json
Normal file
52
composer.json
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"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": "^8.2.0",
|
||||||
|
"illuminate/http": "^11.5",
|
||||||
|
"laravel-zero/framework": "^11.0.0",
|
||||||
|
"symfony/yaml": "^7.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"laravel/pint": "^1.15.2",
|
||||||
|
"mockery/mockery": "^1.6.11",
|
||||||
|
"pestphp/pest": "^2.34.7"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true,
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"pestphp/pest-plugin": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"prefer-stable": true,
|
||||||
|
"bin": ["print-cli"]
|
||||||
|
}
|
||||||
8473
composer.lock
generated
Normal file
8473
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
60
config/app.php
Normal file
60
config/app.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?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' => 'Print-cli',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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 the application utilizes. This can be overridden using
|
||||||
|
| the global command line "--env" option when calling commands.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'env' => 'development',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
83
config/commands.php
Normal file
83
config/commands.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?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\DumpCompletionCommand::class,
|
||||||
|
Symfony\Component\Console\Command\HelpCommand::class,
|
||||||
|
Illuminate\Console\Scheduling\ScheduleRunCommand::class,
|
||||||
|
Illuminate\Console\Scheduling\ScheduleListCommand::class,
|
||||||
|
Illuminate\Console\Scheduling\ScheduleFinishCommand::class,
|
||||||
|
Illuminate\Foundation\Console\VendorPublishCommand::class,
|
||||||
|
LaravelZero\Framework\Commands\StubPublishCommand::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' => [
|
||||||
|
//
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
20
phpunit.xml.dist
Normal file
20
phpunit.xml.dist
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
|
bootstrap="vendor/autoload.php"
|
||||||
|
colors="true"
|
||||||
|
>
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Feature">
|
||||||
|
<directory>./tests/Feature</directory>
|
||||||
|
</testsuite>
|
||||||
|
<testsuite name="Unit">
|
||||||
|
<directory>./tests/Unit</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<source>
|
||||||
|
<include>
|
||||||
|
<directory>./app</directory>
|
||||||
|
</include>
|
||||||
|
</source>
|
||||||
|
</phpunit>
|
||||||
53
print-cli
Normal file
53
print-cli
Normal 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);
|
||||||
6
print-cli.yml
Normal file
6
print-cli.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
base_url: 'https://bitinflow.events'
|
||||||
|
printers:
|
||||||
|
- id: 9c551267-ccdf-42af-92fa-87576416d0ad
|
||||||
|
name: EPSON ET 2750
|
||||||
|
driver: cups
|
||||||
|
address: "ipp://127.0.0.1:631/printers/EPSON_ET_2750_Series_USB"
|
||||||
21
tests/CreatesApplication.php
Normal file
21
tests/CreatesApplication.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
|
||||||
|
trait CreatesApplication
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates the application.
|
||||||
|
*/
|
||||||
|
public function createApplication(): Application
|
||||||
|
{
|
||||||
|
$app = require __DIR__.'/../bootstrap/app.php';
|
||||||
|
|
||||||
|
$app->make(Kernel::class)->bootstrap();
|
||||||
|
|
||||||
|
return $app;
|
||||||
|
}
|
||||||
|
}
|
||||||
5
tests/Feature/InspireCommandTest.php
Normal file
5
tests/Feature/InspireCommandTest.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
it('inspires artisans', function () {
|
||||||
|
$this->artisan('inspire')->assertExitCode(0);
|
||||||
|
});
|
||||||
45
tests/Pest.php
Normal file
45
tests/Pest.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Test Case
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
||||||
|
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
||||||
|
| need to change it using the "uses()" function to bind a different classes or traits.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
uses(Tests\TestCase::class)->in('Feature');
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Expectations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When you're writing tests, you often need to check that values meet certain conditions. The
|
||||||
|
| "expect()" function gives you access to a set of "expectations" methods that you can use
|
||||||
|
| to assert different things. Of course, you may extend the Expectation API at any time.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
expect()->extend('toBeOne', function () {
|
||||||
|
return $this->toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Functions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
||||||
|
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
||||||
|
| global functions to help you to reduce the number of lines of code in your test files.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
function something(): void
|
||||||
|
{
|
||||||
|
// ..
|
||||||
|
}
|
||||||
10
tests/TestCase.php
Normal file
10
tests/TestCase.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
use LaravelZero\Framework\Testing\TestCase as BaseTestCase;
|
||||||
|
|
||||||
|
abstract class TestCase extends BaseTestCase
|
||||||
|
{
|
||||||
|
use CreatesApplication;
|
||||||
|
}
|
||||||
5
tests/Unit/ExampleTest.php
Normal file
5
tests/Unit/ExampleTest.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
test('example', function () {
|
||||||
|
expect(true)->toBeTrue();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user