diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9481819..00cc88a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,15 @@ jobs: - name: Install dependencies run: composer install + - name: Install laravel dependencies (testings purpose) + run: (cd ./tests/_laravel && composer install) + + - name: Create laravel env file + run: (cd ./tests/_laravel && cp .env.example .env) + + - name: Create Laravel Tests app Key + run: (cd ./tests/_laravel && php artisan key:generate) + - name: Run unit tests run: ./vendor/bin/codecept run --coverage --coverage-xml ./coverage.xml diff --git a/.gitignore b/.gitignore index 6ea1d0c..770c47f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # yii console command /yii - +/laravel # phpstorm project files .idea diff --git a/codeception.dist.yml b/codeception.dist.yml index 735fe49..9f0b0bb 100644 --- a/codeception.dist.yml +++ b/codeception.dist.yml @@ -17,8 +17,13 @@ modules: Yii2: configFile: 'tests/_app/config/test.php' cleanup: false + Laravel: + root: 'tests/_laravel/' + cleanup: false coverage: enabled: true whitelist: include: - src/* + exclude: + - src/Providers/* diff --git a/composer.json b/composer.json index 86896be..84ad153 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "ext-gd": "*", "ext-simplexml": "*", "bacon/bacon-qr-code": "^2.0", - "khanamiryan/qrcode-detector-decoder": "^1.0" + "khanamiryan/qrcode-detector-decoder": "^1.0", + "marc-mabe/php-enum": "^4.7" }, "require-dev": { "roave/security-advisories": "dev-master", @@ -50,7 +51,9 @@ "yiisoft/yii2": "^2.0", "codeception/module-filesystem": "^1.0", "codeception/module-yii2": "^1.0", - "codeception/module-asserts": "^1.1" + "codeception/module-asserts": "2.0.1", + "codeception/module-laravel": "^2.1", + "laravel/framework": "^8.83" }, "autoload": { "psr-4": { @@ -60,6 +63,11 @@ "extra": { "branch-alias": { "dev-master": "1.0-dev" + }, + "laravel": { + "providers": [ + "Da\\QrCode\\Providers\\QrCodeServiceProvider" + ] } }, "config": { diff --git a/config/2am-qrcode.php b/config/2am-qrcode.php new file mode 100644 index 0000000..51d15c5 --- /dev/null +++ b/config/2am-qrcode.php @@ -0,0 +1,108 @@ + + '2am', + + /* + |-------------------------------------------------------------------------- + | QR Code Size + |-------------------------------------------------------------------------- + | + | Defines the default size for the generated qrcode. + | + */ + 'size' => 300, + + /* + |-------------------------------------------------------------------------- + | QR Code Margin + |-------------------------------------------------------------------------- + | + | Defines the default margin for the generated qrcode. + | + */ + 'margin' => 15, + + /* + |-------------------------------------------------------------------------- + | QR Code Logo + |-------------------------------------------------------------------------- + | + | Defines the default logo path for the generated qrcode. + | A full path should be provided. + | By default, the logo image will be resized to be square shaped, you can change this + | behavior by setting scaleLogoHeight to true + | + */ + 'logoPath' => null, + + /* + |-------------------------------------------------------------------------- + | QR Scale Logo Height + |-------------------------------------------------------------------------- + | + */ + 'scaleLogoHeight' => false, + + /* + |-------------------------------------------------------------------------- + | QR Logo Size + |-------------------------------------------------------------------------- + | + | Defines the default logo size for the generated qrcode. + | The suggested size is the 16% of the QR Code width + | + */ + 'logoSize' => null, + + /* + |-------------------------------------------------------------------------- + | QR Code Size + |-------------------------------------------------------------------------- + | + | Defines the default size for the generated qrcode. + | + */ + 'background' => [ + 'r' => 255, + 'g' => 255, + 'b' => 255, + ], + + /* + |-------------------------------------------------------------------------- + | QR Code Size + |-------------------------------------------------------------------------- + | + | Defines the default size for the generated qrcode. + | + */ + 'foreground' => [ + 'r' => 0, + 'g' => 0, + 'b' => 0, + 'a' => 100, + ], + + /* + * ------------------------------------------------------------------------ + * QR Code Label Style + * + * Defines the default style for the QR Code label style + * ------------------------------------------------------------------------ + */ + 'label' => [ + 'fontPath' => null, + 'size' => 16, + 'align' => \Da\QrCode\Enums\Label::ALIGN_CENTER, + ] +]; diff --git a/docs/index.md b/docs/index.md index 1fd4936..6cb6257 100644 --- a/docs/index.md +++ b/docs/index.md @@ -15,9 +15,15 @@ it uses a modified version of its code for the writers included on this package. ## Getting Started +### Supported PHP Versions +| Tag | PHP Version | +| :---: |:----------:| +| ^ 3.0.2 | 7.3 - 8.0 | +| 3.1.0 | 7.4 - 8.1 | + ### Server Requirements -- PHP >= 7.3 +- PHP >= 7.4 - Imagick - GD - FreeType @@ -27,12 +33,15 @@ The preferred way to install this extension is through [composer](http://getcomp Either run ``` -php composer.phar require 2amigos/qrcode-library:^3 +php composer.phar require 2amigos/qrcode-library:^3.1.0 ``` or add ```json - "2amigos/qrcode-library": "^3" +{ + ... + "2amigos/qrcode-library": "^3.1.0" +} ``` ### Usage @@ -72,11 +81,13 @@ You can set the foreground color, defining RGBA values, where the alpha is optio $qrCode = (new QrCode('This is my text')) ->setForeground(0, 0, 0); -// or, setting alpha too +// or, setting alpha as well $qrCode = (new QrCode('This is my text')) ->setForeground(0, 0, 0, 50); ``` +### Formats + In order to ease the task to write different formats into a QrCode, the library comes with a set of classes. These are: - [BookmarkFormat](formats/bookmark.md) @@ -93,6 +104,15 @@ In order to ease the task to write different formats into a QrCode, the library - [WifiFormat](formats/wifi.md) - [YoutubeFormat](formats/youtube.md) +Laravel +---- + +This library bundles a blade component and a file route to easily work with the Laravel framework. + +- [LaravelBladeComponent](laravel/blade-component.md) +- [File Route](laravel/file-route.md) +- [Customization](laravel/customization.md) + Yii2 ---- diff --git a/docs/laravel/blade-component.md b/docs/laravel/blade-component.md new file mode 100644 index 0000000..b4846d8 --- /dev/null +++ b/docs/laravel/blade-component.md @@ -0,0 +1,89 @@ +Laravel Blade Component +---- + +This library realeases a blade component to make it easy to build qrcode with the Laravel Framework. + +Before get started, make sure you have the class `\Da\QrCode\Providers\QrCodeServiceProvider::class` +listed on you config/app.php file, on providers section. + +```php +[ + ... + 'providers' => [ + ... + \Da\QrCode\Providers\QrCodeServiceProvider::class, + ], +]; +``` + +With the provider set, we can create a qrcode using the `2am-qrcode` blade component. +It has only `content` as a required field. + +```html + +``` + +We can also define the qrcode [format](../index.md#Formats). To do so, +you must specify the `format` attribute with a constant from `\Da\QrCode\Enum\Format` and the `content` as an array, +fulfilling the data for the designed format as specified in the format [docs]((../index.md#Formats)). + +To work with colors (background, foreground and gradient foreground), you set +the attributes `background`, `foregroud` and `foreground2` (for gradient foreground) as an array +having the keys `r`, `g`, `b` (and `a` to set alpha on foreground, but it's optional). + +```php +$background = [ + 'r' => 200, + 'g' => 200, + 'b' => 200, +]; + +$foreground = [ + 'r' => 0, + 'b' => 255, + 'g' => 0, +]; + +$foreground2 = [ + 'r' => 0, + 'b' => 0, + 'g' => 255, +]; + +$content = [ + 'title' => '2am. Technologies', + 'url' => 'https://2am.tech', +]; +``` + +```html + +``` + +All blade component attributes: + +| Attribute | Description | Data Type | +|:---------:|:--------------------------------------------------------------------------:|:----------------------------------------------:| +| content | Defines the qrcode's data | string; array | +| format | Defines the qrcode's format | \Da\QrCode\Enum\Format | +| foreground | Defines the qrcode`s foreground base color | array (r, g, b, a) | +| background | Defines the qrcode's background color | array (r, g, b, a) | +| foreground2 | Defines the qrcode's foreground end color (turns to gradient) | array (r, g, b, a) | +| pathStyle | Defines the qrcode's path style | \Da\QrCode\Enum\Path | +| intensity | Defines the path style intensity | float, from 0.1 to 1 | +| margin | Defines the qrcode's margin | int | +| size | Defines the qrcode's size | int | +| logoPath | Set a image to be displayed in the qrcode's center | string; it should be full path | +| logoSize | Set the qrcode's logo size. | int. Recomended size is 16% from qrcode's size | +| scaleLogoHeight | Set if the logo's image should be scaled instead of croped to square shape | bool. Default is false | +| gradientType | Defines the gradient type | \Da\QrCode\Enums\Gradient | +| label | Defines the qrcode's label | string | +| font | Defines the label font | string. It should be full path | +| fontSize | Defines the label font size | int | +| fontAlign | Defines the label alignment | \Da\QrCode\Label | \ No newline at end of file diff --git a/docs/laravel/customization.md b/docs/laravel/customization.md new file mode 100644 index 0000000..2e8c3a6 --- /dev/null +++ b/docs/laravel/customization.md @@ -0,0 +1,18 @@ +Laravel Blade Component +---- + +You can publish the qrcode's config file by executing the given command: + +```bash +$ php artisan vendor:publish --tag=2am-qrcode-config +``` + +This will create a file name 2am-qrcode.php under your config folder, where you can +set the default look of your qrcode and the component prefix. + +By the next command, you can publish the component related view, enabling you to perform your +own customization to component structure. + +```bash +$ php artisan vendor:publish --tag=2am-qrcode-views +``` \ No newline at end of file diff --git a/docs/laravel/file-route.md b/docs/laravel/file-route.md new file mode 100644 index 0000000..cc0fb27 --- /dev/null +++ b/docs/laravel/file-route.md @@ -0,0 +1,44 @@ +Laravel File Route +---- + +This library realeases a blade component to make it easy to build qrcode with the Laravel Framework. + +Before get started, make sure you have the class `\Da\QrCode\Providers\QrCodeServiceProvider::class` +listed on you config/app.php file, on providers section. + +```php +[ + ... + 'providers' => [ + ... + \Da\QrCode\Providers\QrCodeServiceProvider::class, + ], +]; +``` + +The file route is registered as `/da-qrcode/build` and it has only one required parameter: `content`. + +You can test this resource by accessing the endpoint, e.g `/da-qrcode/build?content=2am. Technologies` + +As optional parameters it has: + +- label; +- margin; and +- size + +Here is a complete sample of usage: + +```html + + + + +``` \ No newline at end of file diff --git a/resources/views/components/qrcode.blade.php b/resources/views/components/qrcode.blade.php new file mode 100644 index 0000000..37858bb --- /dev/null +++ b/resources/views/components/qrcode.blade.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/routes/laravel.route.php b/routes/laravel.route.php new file mode 100644 index 0000000..0f7b77a --- /dev/null +++ b/routes/laravel.route.php @@ -0,0 +1,8 @@ +name('da-qrcode.')->group(function () { + Route::get('/build', LaravelResourceController::class)->name('build'); +}); diff --git a/src/Component/QrCodeBladeComponent.php b/src/Component/QrCodeBladeComponent.php new file mode 100644 index 0000000..2a8680f --- /dev/null +++ b/src/Component/QrCodeBladeComponent.php @@ -0,0 +1,174 @@ +content = $content; + $this->format = $format; + $this->foreground = $foreground; + $this->background = $background; + $this->foreground2 = $foreground2; + $this->pathStyle = $pathStyle; + $this->intensity = $intensity; + $this->margin = $margin; + $this->size = $size; + $this->logoPath = $logoPath; + $this->logoSize = $logoSize; + $this->scaleLogoHeight = $scaleLogoHeight; + $this->gradientType = $gradientType; + $this->label = $label; + $this->fontPath = $font; + $this->fontSize = $fontSize; + $this->alignment = $fontAlign; + } + + /** + * @return string + * @throws Exception + */ + public function buildQrCodeUri(): string + { + $qrCode = LaravelQrCodeFactory::make( + $this->content, + $this->format, + $this->foreground, + $this->background, + $this->pathStyle, + $this->intensity, + $this->foreground2, + $this->margin, + $this->size, + $this->logoPath, + $this->logoSize, + $this->scaleLogoHeight, + $this->gradientType, + $this->label, + $this->fontPath, + $this->fontSize, + $this->alignment + ); + + return $qrCode->writeDataUri(); + } + + public function render() + { + return view('2am-qrcode::components.qrcode'); + } +} diff --git a/src/Contracts/ColorsInterface.php b/src/Contracts/ColorsInterface.php index 9a44979..ada98f4 100644 --- a/src/Contracts/ColorsInterface.php +++ b/src/Contracts/ColorsInterface.php @@ -75,4 +75,4 @@ public function buildFillColor(); * @return void */ public function forceUniformRgbColors(): void; -} \ No newline at end of file +} diff --git a/src/Contracts/PathStyleInterface.php b/src/Contracts/PathStyleInterface.php index c91dab3..ed6c99a 100644 --- a/src/Contracts/PathStyleInterface.php +++ b/src/Contracts/PathStyleInterface.php @@ -42,4 +42,4 @@ public function buildModule(); * @return EyeInterface */ public function buildEye(); -} \ No newline at end of file +} diff --git a/src/Controllers/LaravelResourceController.php b/src/Controllers/LaravelResourceController.php new file mode 100644 index 0000000..10bd78a --- /dev/null +++ b/src/Controllers/LaravelResourceController.php @@ -0,0 +1,56 @@ +only([ + 'content', + 'label', + 'margin', + 'size', + ]); + + if (! isset($data['content'])) { + throw new Exception('The param `content` is required'); + } + + $qrCode = LaravelQrCodeFactory::make( + $data['content'], + null, + null, + null, + null, + null, + null, + $data['margin'] ?? null, + $data['size'] ?? null, + null, + null, + null, + null, + $data['label'] ?? null + ); + + return response($qrCode->writeString()) + ->withHeaders([ + 'Content-Type' => $qrCode->getContentType(), + ]); + } +} diff --git a/src/Enums/Format.php b/src/Enums/Format.php new file mode 100644 index 0000000..b430480 --- /dev/null +++ b/src/Enums/Format.php @@ -0,0 +1,36 @@ +setForegroundColor( + $foreground['r'], + $foreground['g'], + $foreground['b'], + isset($foreground['a']) ? $foreground['a'] : 100, + ); + } + + /** + * @param QrCodeInterface $qrCode + * @param array|null $foreground2 + * @param string|null $gradientType + * @return void + */ + protected static function applyForeground2( + QrCodeInterface $qrCode, + ?array $foreground2, + ?string $gradientType + ): void { + if (is_null($foreground2)) { + return; + } + + $qrCode->setForegroundEndColor( + $foreground2['r'], + $foreground2['g'], + $foreground2['b'], + isset($foreground2['a']) ? $foreground2['a'] : 100, + ); + + if (is_null($gradientType)) { + return; + } + + $qrCode->setGradientType($gradientType); + } + + /** + * @param QrCodeInterface $qrCode + * @param array|null $background + * @return void + */ + protected static function applyBackground(QrCodeInterface $qrCode, ?array $background): void + { + $background = $background ?: config('2am-qrcode.background'); + + $qrCode->setbackgroundColor( + $background['r'], + $background['g'], + $background['b'], + ); + } + + /** + * @param QrCodeInterface $qrCode + * @param string|null $style + * @param float|null $intensity + * @return void + */ + protected static function applyPathStyle(QrCodeInterface $qrCode, ?string $style, ?float $intensity): void + { + if (!is_null($style)) { + $qrCode->setPathStyle($style); + } + + if (!is_null($intensity)) { + $qrCode->setPathIntensity($intensity); + } + } + + /** + * @param QrCodeInterface $qrCode + * @param int|null $margin + * @return void + */ + protected static function applyMargin(QrCodeInterface $qrCode, ?int $margin): void + { + $margin = $margin ?: config('2am-qrcode.margin'); + + $qrCode->setMargin($margin); + } + + /** + * @param QrCodeInterface $qrCode + * @param int|null $size + * @return void + */ + protected static function applySize(QrCodeInterface $qrCode, ?int $size): void + { + $size = $size ?: config('2am-qrcode.size'); + + $qrCode->setSize($size); + } + + /** + * @param QrCodeInterface $qrCode + * @param string|null $logoPath + * @param int|null $logoSize + * @param bool|null $scale + * @return void + * @throws \Da\QrCode\Exception\InvalidPathException + */ + protected static function applyLogo(QrCodeInterface $qrCode, ?string $logoPath, ?int $logoSize, ?bool $scale): void + { + $logoPath = $logoPath ?: config('2am-qrcode.logoPath'); + $logoSize = $logoSize ?: config('2am-qrcode.logoSize'); + $scale = $scale ?: config('2am-qrcode.scaleLogoHeight'); + + if (is_null($logoPath)) { + return; + } + + $qrCode->setLogo($logoPath); + + if (!is_null($logoSize) && is_numeric($logoSize)) { + $qrCode->setLogoWidth((int)$logoSize); + } + + if ($scale) { + $qrCode->setScaleLogoHeight($scale); + } + } + + /** + * @param string|array $content + * @param string|null $format + * @throws Exception + * @return QrCode + */ + protected static function buildQrCode($content, ?string $format): QrCodeInterface + { + self::validate($content, $format); + + if (is_null($format) || $format === Format::TEXT) { + return is_array($content) + ? new QrCode($content['text']) + : new QrCode($content); + } + + $qrCodeFormat = new $format($content); + + return new QrCode($qrCodeFormat->getText()); + } + + protected static function applyLabel( + QrCodeInterface $qrCode, + ?string $label = null, + ?string $fontPath = null, + ?int $size = null, + ?string $alignment = null + ): void { + if (! is_null($label)) { + $qrCode->setLabel(new Label( + $label, + $fontPath ?? config('2am-qrcode.label.fontPath'), + $size ?? config('2am-qrcode.label.size'), + $alignment ?? config('2am-qrcode.label.align') + )); + } + } + + /** + * @param string|array $content + * @param string|null $format + * @return void + * @throws Exception + */ + protected static function validate($content, ?string $format): void + { + if (! is_array($content) && ! is_string($content)) { + throw new Exception( + 'Invalid content. It should be String or Array, ' + . gettype($content) + . ' given' + ); + } + + if (! is_null($format) && $format !== 'text' && ! class_exists($format)) { + throw new Exception( + 'Invalid format. The given format class , `' + . $format + . '` does not exists' + ); + } + + if (! is_null($format) && $format !== 'text' && ! (new $format($content)) instanceof AbstractFormat) { + throw new Exception( + 'Invalid format. It should be instance of Enum or null, ' + . gettype($format) + . ' given' + ); + } + } +} diff --git a/src/Providers/QrCodeServiceProvider.php b/src/Providers/QrCodeServiceProvider.php new file mode 100644 index 0000000..7ed7aa0 --- /dev/null +++ b/src/Providers/QrCodeServiceProvider.php @@ -0,0 +1,31 @@ +loadViewsFrom(__DIR__ . '/../../resources/views', '2am-qrcode'); + /** Load package routes */ + $this->loadRoutesFrom(__DIR__ . '/../../routes/laravel.route.php'); + /** publishes package config */ + $this->publishes([ + __DIR__ . '/../../config/2am-qrcode.php' => config_path('2am-qrcode.php'), + ], '2am-qrcode-config'); + $this->publishes([ + __DIR__ . '/../../resources/views' => resource_path('views/vendor/2am-qrcode'), + ], '2am-qrcode-views'); + /** merges config file with user's published version */ + $this->mergeConfigFrom(__DIR__ . '/../../config/2am-qrcode.php', '2am-qrcode'); + /** Declares package's components */ + Blade::component('qrcode', QrCodeBladeComponent::class, config('2am-qrcode.prefix')); + } +} diff --git a/src/StyleManager.php b/src/StyleManager.php index 68b1515..2ff450a 100644 --- a/src/StyleManager.php +++ b/src/StyleManager.php @@ -14,6 +14,7 @@ use BaconQrCode\Renderer\RendererStyle\Gradient; use BaconQrCode\Renderer\RendererStyle\GradientType; use Da\QrCode\Contracts\ColorsInterface; +use Da\QrCode\Enums\Gradient as GradientEnum; use Da\QrCode\Contracts\PathStyleInterface; use Exception; @@ -52,14 +53,19 @@ class StyleManager implements PathStyleInterface, ColorsInterface * @param string|null $gradientType * @throws Exception */ - public function __construct($foregroundColor, $backgroundColor, string $pathStyle = null, float $styleIntensity = null, $gradientType = null) - { + public function __construct( + $foregroundColor, + $backgroundColor, + string $pathStyle = null, + float $styleIntensity = null, + $gradientType = null + ) { $this->setForegroundColor($foregroundColor); $this->setBackgroundColor($backgroundColor); $this->pathStyle = $pathStyle ?: PathStyleInterface::SQUARE; $this->styleIntensity = $styleIntensity ?: 1; - $this->gradientType = $gradientType ?: ColorsInterface::GRADIENT_VERTICAL; + $this->gradientType = $gradientType ?: GradientEnum::GRADIENT_VERTICAL; } /** @@ -174,22 +180,16 @@ public function setGradientType(string $type): void public function getGradientTye() { switch ($this->gradientType) { - case ColorsInterface::GRADIENT_VERTICAL: { - return GradientType::VERTICAL(); - } - case ColorsInterface::GRADIENT_DIAGONAL: { + case GradientEnum::GRADIENT_DIAGONAL: return GradientType::DIAGONAL(); - } - case ColorsInterface::GRADIENT_INVERSE_DIAGONAL: { + case GradientEnum::GRADIENT_INVERSE_DIAGONAL: return GradientType::INVERSE_DIAGONAL(); - } - case ColorsInterface::GRADIENT_HORIZONTAL: { + case GradientEnum::GRADIENT_HORIZONTAL: return GradientType::HORIZONTAL(); - } - case ColorsInterface::GRADIENT_RADIAL: { + case GradientEnum::GRADIENT_RADIAL: return GradientType::RADIAL(); - } - default: return GradientType::VERTICAL(); + default: + return GradientType::VERTICAL(); } } @@ -244,12 +244,11 @@ public function buildFillColor() ) ); } - else { - return Fill::uniformColor( - $this->getBackgroundColor(), - $this->getForegroundColor() - ); - } + + return Fill::uniformColor( + $this->getBackgroundColor(), + $this->getForegroundColor() + ); } /** @@ -258,9 +257,12 @@ public function buildFillColor() public function buildModule() { switch ($this->getPathStyle()) { - case PathStyleInterface::DOTS: return new DotsModule($this->getIntensity()); - case PathStyleInterface::ROUNDED: return new RoundnessModule($this->getIntensity()); - default: return SquareModule::instance(); + case PathStyleInterface::DOTS: + return new DotsModule($this->getIntensity()); + case PathStyleInterface::ROUNDED: + return new RoundnessModule($this->getIntensity()); + default: + return SquareModule::instance(); } } @@ -271,4 +273,4 @@ public function buildEye() { return new ModuleEye($this->buildModule()); } -} \ No newline at end of file +} diff --git a/src/Writer/EpsWriter.php b/src/Writer/EpsWriter.php index 89d1308..be7bbce 100644 --- a/src/Writer/EpsWriter.php +++ b/src/Writer/EpsWriter.php @@ -32,7 +32,7 @@ public function __construct() */ public function writeString(QrCodeInterface $qrCode): string { - $renderer = $this->buildRenderer($qrCode);; + $renderer = $this->buildRenderer($qrCode); $writer = new Writer($renderer); diff --git a/tests/_data/blade/endpoint.png b/tests/_data/blade/endpoint.png new file mode 100644 index 0000000..e5805f8 Binary files /dev/null and b/tests/_data/blade/endpoint.png differ diff --git a/tests/_data/blade/endpoint2.png b/tests/_data/blade/endpoint2.png new file mode 100644 index 0000000..3f90eb6 Binary files /dev/null and b/tests/_data/blade/endpoint2.png differ diff --git a/tests/_data/blade/endpoint3.png b/tests/_data/blade/endpoint3.png new file mode 100644 index 0000000..586b6e1 Binary files /dev/null and b/tests/_data/blade/endpoint3.png differ diff --git a/tests/_data/blade/endpoint4.png b/tests/_data/blade/endpoint4.png new file mode 100644 index 0000000..4c1bd83 Binary files /dev/null and b/tests/_data/blade/endpoint4.png differ diff --git a/tests/_data/blade/qrcode-background.png b/tests/_data/blade/qrcode-background.png new file mode 100644 index 0000000..1c897b8 Binary files /dev/null and b/tests/_data/blade/qrcode-background.png differ diff --git a/tests/_data/blade/qrcode-blade.png b/tests/_data/blade/qrcode-blade.png new file mode 100644 index 0000000..e5805f8 Binary files /dev/null and b/tests/_data/blade/qrcode-blade.png differ diff --git a/tests/_data/blade/qrcode-dots.png b/tests/_data/blade/qrcode-dots.png new file mode 100644 index 0000000..07eb489 Binary files /dev/null and b/tests/_data/blade/qrcode-dots.png differ diff --git a/tests/_data/blade/qrcode-foreground.png b/tests/_data/blade/qrcode-foreground.png new file mode 100644 index 0000000..45d2e0d Binary files /dev/null and b/tests/_data/blade/qrcode-foreground.png differ diff --git a/tests/_data/blade/qrcode-gradient-radial.png b/tests/_data/blade/qrcode-gradient-radial.png new file mode 100644 index 0000000..d2e3914 Binary files /dev/null and b/tests/_data/blade/qrcode-gradient-radial.png differ diff --git a/tests/_data/blade/qrcode-gradient.png b/tests/_data/blade/qrcode-gradient.png new file mode 100644 index 0000000..b7b6937 Binary files /dev/null and b/tests/_data/blade/qrcode-gradient.png differ diff --git a/tests/_data/blade/qrcode-label.png b/tests/_data/blade/qrcode-label.png new file mode 100644 index 0000000..0d8a836 Binary files /dev/null and b/tests/_data/blade/qrcode-label.png differ diff --git a/tests/_data/blade/qrcode-logo.png b/tests/_data/blade/qrcode-logo.png new file mode 100644 index 0000000..fb16f59 Binary files /dev/null and b/tests/_data/blade/qrcode-logo.png differ diff --git a/tests/_data/blade/qrcode-logo2.png b/tests/_data/blade/qrcode-logo2.png new file mode 100644 index 0000000..66c5a38 Binary files /dev/null and b/tests/_data/blade/qrcode-logo2.png differ diff --git a/tests/_data/blade/qrcode-rounded.png b/tests/_data/blade/qrcode-rounded.png new file mode 100644 index 0000000..ded27db Binary files /dev/null and b/tests/_data/blade/qrcode-rounded.png differ diff --git a/tests/_laravel/.editorconfig b/tests/_laravel/.editorconfig new file mode 100644 index 0000000..1671c9b --- /dev/null +++ b/tests/_laravel/.editorconfig @@ -0,0 +1,18 @@ +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,yaml}] +indent_size = 2 + +[docker-compose.yml] +indent_size = 4 diff --git a/tests/_laravel/.env.example b/tests/_laravel/.env.example new file mode 100644 index 0000000..44853cd --- /dev/null +++ b/tests/_laravel/.env.example @@ -0,0 +1,51 @@ +APP_NAME=Laravel +APP_ENV=local +APP_KEY= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack +LOG_LEVEL=debug + +DB_CONNECTION=mysql +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=laravel +DB_USERNAME=root +DB_PASSWORD= + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +FILESYSTEM_DRIVER=local +QUEUE_CONNECTION=sync +SESSION_DRIVER=file +SESSION_LIFETIME=120 + +MEMCACHED_HOST=127.0.0.1 + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=smtp +MAIL_HOST=mailhog +MAIL_PORT=1025 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS=null +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= +AWS_USE_PATH_STYLE_ENDPOINT=false + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/tests/_laravel/.gitattributes b/tests/_laravel/.gitattributes new file mode 100644 index 0000000..967315d --- /dev/null +++ b/tests/_laravel/.gitattributes @@ -0,0 +1,5 @@ +* text=auto +*.css linguist-vendored +*.scss linguist-vendored +*.js linguist-vendored +CHANGELOG.md export-ignore diff --git a/tests/_laravel/.gitignore b/tests/_laravel/.gitignore new file mode 100644 index 0000000..eb003b0 --- /dev/null +++ b/tests/_laravel/.gitignore @@ -0,0 +1,15 @@ +/node_modules +/public/hot +/public/storage +/storage/*.key +/vendor +.env +.env.backup +.phpunit.result.cache +docker-compose.override.yml +Homestead.json +Homestead.yaml +npm-debug.log +yarn-error.log +/.idea +/.vscode diff --git a/tests/_laravel/.styleci.yml b/tests/_laravel/.styleci.yml new file mode 100644 index 0000000..877ea70 --- /dev/null +++ b/tests/_laravel/.styleci.yml @@ -0,0 +1,14 @@ +php: + preset: laravel + version: 8 + disabled: + - no_unused_imports + finder: + not-name: + - index.php + - server.php +js: + finder: + not-name: + - webpack.mix.js +css: true diff --git a/tests/_laravel/README.md b/tests/_laravel/README.md new file mode 100644 index 0000000..49c38be --- /dev/null +++ b/tests/_laravel/README.md @@ -0,0 +1,64 @@ +

+ +

+Build Status +Total Downloads +Latest Stable Version +License +

+ +## About Laravel + +Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: + +- [Simple, fast routing engine](https://laravel.com/docs/routing). +- [Powerful dependency injection container](https://laravel.com/docs/container). +- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. +- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). +- Database agnostic [schema migrations](https://laravel.com/docs/migrations). +- [Robust background job processing](https://laravel.com/docs/queues). +- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). + +Laravel is accessible, powerful, and provides tools required for large, robust applications. + +## Learning Laravel + +Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. + +If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. + +## Laravel Sponsors + +We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). + +### Premium Partners + +- **[Vehikl](https://vehikl.com/)** +- **[Tighten Co.](https://tighten.co)** +- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** +- **[64 Robots](https://64robots.com)** +- **[Cubet Techno Labs](https://cubettech.com)** +- **[Cyber-Duck](https://cyber-duck.co.uk)** +- **[Many](https://www.many.co.uk)** +- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** +- **[DevSquad](https://devsquad.com)** +- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** +- **[OP.GG](https://op.gg)** +- **[CMS Max](https://www.cmsmax.com/)** +- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** + +## Contributing + +Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). + +## Code of Conduct + +In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). + +## Security Vulnerabilities + +If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. + +## License + +The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/tests/_laravel/app/Console/Kernel.php b/tests/_laravel/app/Console/Kernel.php new file mode 100644 index 0000000..69914e9 --- /dev/null +++ b/tests/_laravel/app/Console/Kernel.php @@ -0,0 +1,41 @@ +command('inspire')->hourly(); + } + + /** + * Register the commands for the application. + * + * @return void + */ + protected function commands() + { + $this->load(__DIR__.'/Commands'); + + require base_path('routes/console.php'); + } +} diff --git a/tests/_laravel/app/Exceptions/Handler.php b/tests/_laravel/app/Exceptions/Handler.php new file mode 100644 index 0000000..c18c43c --- /dev/null +++ b/tests/_laravel/app/Exceptions/Handler.php @@ -0,0 +1,41 @@ +reportable(function (Throwable $e) { + // + }); + } +} diff --git a/tests/_laravel/app/Http/Controllers/Controller.php b/tests/_laravel/app/Http/Controllers/Controller.php new file mode 100644 index 0000000..a0a2a8a --- /dev/null +++ b/tests/_laravel/app/Http/Controllers/Controller.php @@ -0,0 +1,13 @@ + [ + \App\Http\Middleware\EncryptCookies::class, + \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, + \Illuminate\Session\Middleware\StartSession::class, + // \Illuminate\Session\Middleware\AuthenticateSession::class, + \Illuminate\View\Middleware\ShareErrorsFromSession::class, + \App\Http\Middleware\VerifyCsrfToken::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + + 'api' => [ + // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, + 'throttle:api', + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], + ]; + + /** + * The application's route middleware. + * + * These middleware may be assigned to groups or used individually. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, + 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + ]; +} diff --git a/tests/_laravel/app/Http/Middleware/Authenticate.php b/tests/_laravel/app/Http/Middleware/Authenticate.php new file mode 100644 index 0000000..704089a --- /dev/null +++ b/tests/_laravel/app/Http/Middleware/Authenticate.php @@ -0,0 +1,21 @@ +expectsJson()) { + return route('login'); + } + } +} diff --git a/tests/_laravel/app/Http/Middleware/EncryptCookies.php b/tests/_laravel/app/Http/Middleware/EncryptCookies.php new file mode 100644 index 0000000..033136a --- /dev/null +++ b/tests/_laravel/app/Http/Middleware/EncryptCookies.php @@ -0,0 +1,17 @@ +check()) { + return redirect(RouteServiceProvider::HOME); + } + } + + return $next($request); + } +} diff --git a/tests/_laravel/app/Http/Middleware/TrimStrings.php b/tests/_laravel/app/Http/Middleware/TrimStrings.php new file mode 100644 index 0000000..a8a252d --- /dev/null +++ b/tests/_laravel/app/Http/Middleware/TrimStrings.php @@ -0,0 +1,19 @@ +allSubdomainsOfApplicationUrl(), + ]; + } +} diff --git a/tests/_laravel/app/Http/Middleware/TrustProxies.php b/tests/_laravel/app/Http/Middleware/TrustProxies.php new file mode 100644 index 0000000..d11dd5f --- /dev/null +++ b/tests/_laravel/app/Http/Middleware/TrustProxies.php @@ -0,0 +1,23 @@ + 'datetime', + ]; +} diff --git a/tests/_laravel/app/Providers/AppServiceProvider.php b/tests/_laravel/app/Providers/AppServiceProvider.php new file mode 100644 index 0000000..ee8ca5b --- /dev/null +++ b/tests/_laravel/app/Providers/AppServiceProvider.php @@ -0,0 +1,28 @@ + 'App\Policies\ModelPolicy', + ]; + + /** + * Register any authentication / authorization services. + * + * @return void + */ + public function boot() + { + $this->registerPolicies(); + + // + } +} diff --git a/tests/_laravel/app/Providers/BroadcastServiceProvider.php b/tests/_laravel/app/Providers/BroadcastServiceProvider.php new file mode 100644 index 0000000..395c518 --- /dev/null +++ b/tests/_laravel/app/Providers/BroadcastServiceProvider.php @@ -0,0 +1,21 @@ + [ + SendEmailVerificationNotification::class, + ], + ]; + + /** + * Register any events for your application. + * + * @return void + */ + public function boot() + { + // + } +} diff --git a/tests/_laravel/app/Providers/RouteServiceProvider.php b/tests/_laravel/app/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..3bd3c81 --- /dev/null +++ b/tests/_laravel/app/Providers/RouteServiceProvider.php @@ -0,0 +1,63 @@ +configureRateLimiting(); + + $this->routes(function () { + Route::prefix('api') + ->middleware('api') + ->namespace($this->namespace) + ->group(base_path('routes/api.php')); + + Route::middleware('web') + ->namespace($this->namespace) + ->group(base_path('routes/web.php')); + }); + } + + /** + * Configure the rate limiters for the application. + * + * @return void + */ + protected function configureRateLimiting() + { + RateLimiter::for('api', function (Request $request) { + return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); + }); + } +} diff --git a/tests/_laravel/artisan b/tests/_laravel/artisan new file mode 100644 index 0000000..67a3329 --- /dev/null +++ b/tests/_laravel/artisan @@ -0,0 +1,53 @@ +#!/usr/bin/env php +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); diff --git a/tests/_laravel/bootstrap/app.php b/tests/_laravel/bootstrap/app.php new file mode 100644 index 0000000..037e17d --- /dev/null +++ b/tests/_laravel/bootstrap/app.php @@ -0,0 +1,55 @@ +singleton( + Illuminate\Contracts\Http\Kernel::class, + App\Http\Kernel::class +); + +$app->singleton( + Illuminate\Contracts\Console\Kernel::class, + App\Console\Kernel::class +); + +$app->singleton( + Illuminate\Contracts\Debug\ExceptionHandler::class, + App\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; diff --git a/tests/_laravel/bootstrap/cache/.gitignore b/tests/_laravel/bootstrap/cache/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/_laravel/bootstrap/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/_laravel/composer.json b/tests/_laravel/composer.json new file mode 100644 index 0000000..e1a9c43 --- /dev/null +++ b/tests/_laravel/composer.json @@ -0,0 +1,64 @@ +{ + "name": "laravel/laravel", + "type": "project", + "description": "The Laravel Framework.", + "keywords": ["framework", "laravel"], + "license": "MIT", + "require": { + "php": "^7.3|^8.0", + "fruitcake/laravel-cors": "^2.0", + "guzzlehttp/guzzle": "^7.0.1", + "laravel/framework": "^8.54", + "laravel/sanctum": "^2.11", + "laravel/tinker": "^2.5", + "marc-mabe/php-enum": "^4.7" + }, + "require-dev": { + "facade/ignition": "^2.5", + "fakerphp/faker": "^1.9.1", + "laravel/sail": "^1.0.1", + "mockery/mockery": "^1.4.2", + "nunomaduro/collision": "^5.0", + "phpunit/phpunit": "^9.3.3" + }, + "autoload": { + "psr-4": { + "App\\": "app/", + "Da\\QrCode\\": "./../../src/", + "Database\\Factories\\": "database/factories/", + "Database\\Seeders\\": "database/seeders/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "scripts": { + "post-autoload-dump": [ + "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", + "@php artisan package:discover --ansi" + ], + "post-update-cmd": [ + "@php artisan vendor:publish --tag=laravel-assets --ansi" + ], + "post-root-package-install": [ + "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" + ], + "post-create-project-cmd": [ + "@php artisan key:generate --ansi" + ] + }, + "extra": { + "laravel": { + "dont-discover": [] + } + }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/tests/_laravel/config/app.php b/tests/_laravel/config/app.php new file mode 100644 index 0000000..258078f --- /dev/null +++ b/tests/_laravel/config/app.php @@ -0,0 +1,233 @@ + env('APP_NAME', 'Laravel'), + + /* + |-------------------------------------------------------------------------- + | 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. Set this in your ".env" file. + | + */ + + 'env' => env('APP_ENV', 'production'), + + /* + |-------------------------------------------------------------------------- + | Application Debug Mode + |-------------------------------------------------------------------------- + | + | When your application is in debug mode, detailed error messages with + | stack traces will be shown on every error that occurs within your + | application. If disabled, a simple generic error page is shown. + | + */ + + 'debug' => (bool) env('APP_DEBUG', false), + + /* + |-------------------------------------------------------------------------- + | Application URL + |-------------------------------------------------------------------------- + | + | This URL is used by the console to properly generate URLs when using + | the Artisan command line tool. You should set this to the root of + | your application so that it is used when running Artisan tasks. + | + */ + + 'url' => env('APP_URL', 'http://localhost'), + + 'asset_url' => env('ASSET_URL', null), + + /* + |-------------------------------------------------------------------------- + | Application Timezone + |-------------------------------------------------------------------------- + | + | Here you may specify the default timezone for your application, which + | will be used by the PHP date and date-time functions. We have gone + | ahead and set this to a sensible default for you out of the box. + | + */ + + 'timezone' => 'UTC', + + /* + |-------------------------------------------------------------------------- + | Application Locale Configuration + |-------------------------------------------------------------------------- + | + | The application locale determines the default locale that will be used + | by the translation service provider. You are free to set this value + | to any of the locales which will be supported by the application. + | + */ + + 'locale' => 'en', + + /* + |-------------------------------------------------------------------------- + | Application Fallback Locale + |-------------------------------------------------------------------------- + | + | The fallback locale determines the locale to use when the current one + | is not available. You may change the value to correspond to any of + | the language folders that are provided through your application. + | + */ + + 'fallback_locale' => 'en', + + /* + |-------------------------------------------------------------------------- + | Faker Locale + |-------------------------------------------------------------------------- + | + | This locale will be used by the Faker PHP library when generating fake + | data for your database seeds. For example, this will be used to get + | localized telephone numbers, street address information and more. + | + */ + + 'faker_locale' => 'en_US', + + /* + |-------------------------------------------------------------------------- + | Encryption Key + |-------------------------------------------------------------------------- + | + | This key is used by the Illuminate encrypter service and should be set + | to a random, 32 character string, otherwise these encrypted strings + | will not be safe. Please do this before deploying an application! + | + */ + + 'key' => env('APP_KEY'), + + 'cipher' => 'AES-256-CBC', + + /* + |-------------------------------------------------------------------------- + | 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' => [ + + /* + * Laravel Framework Service Providers... + */ + Illuminate\Auth\AuthServiceProvider::class, + Illuminate\Broadcasting\BroadcastServiceProvider::class, + Illuminate\Bus\BusServiceProvider::class, + Illuminate\Cache\CacheServiceProvider::class, + Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, + Illuminate\Cookie\CookieServiceProvider::class, + Illuminate\Database\DatabaseServiceProvider::class, + Illuminate\Encryption\EncryptionServiceProvider::class, + Illuminate\Filesystem\FilesystemServiceProvider::class, + Illuminate\Foundation\Providers\FoundationServiceProvider::class, + Illuminate\Hashing\HashServiceProvider::class, + Illuminate\Mail\MailServiceProvider::class, + Illuminate\Notifications\NotificationServiceProvider::class, + Illuminate\Pagination\PaginationServiceProvider::class, + Illuminate\Pipeline\PipelineServiceProvider::class, + Illuminate\Queue\QueueServiceProvider::class, + Illuminate\Redis\RedisServiceProvider::class, + Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, + Illuminate\Session\SessionServiceProvider::class, + Illuminate\Translation\TranslationServiceProvider::class, + Illuminate\Validation\ValidationServiceProvider::class, + Illuminate\View\ViewServiceProvider::class, + + /* + * Package Service Providers... + */ + \Da\QrCode\Providers\QrCodeServiceProvider::class, + /* + * Application Service Providers... + */ + App\Providers\AppServiceProvider::class, + App\Providers\AuthServiceProvider::class, + // App\Providers\BroadcastServiceProvider::class, + App\Providers\EventServiceProvider::class, + App\Providers\RouteServiceProvider::class, + ], + + /* + |-------------------------------------------------------------------------- + | Class Aliases + |-------------------------------------------------------------------------- + | + | This array of class aliases will be registered when this application + | is started. However, feel free to register as many as you wish as + | the aliases are "lazy" loaded so they don't hinder performance. + | + */ + + 'aliases' => [ + + 'App' => Illuminate\Support\Facades\App::class, + 'Arr' => Illuminate\Support\Arr::class, + 'Artisan' => Illuminate\Support\Facades\Artisan::class, + 'Auth' => Illuminate\Support\Facades\Auth::class, + 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, + 'Bus' => Illuminate\Support\Facades\Bus::class, + 'Cache' => Illuminate\Support\Facades\Cache::class, + 'Config' => Illuminate\Support\Facades\Config::class, + 'Cookie' => Illuminate\Support\Facades\Cookie::class, + 'Crypt' => Illuminate\Support\Facades\Crypt::class, + 'Date' => Illuminate\Support\Facades\Date::class, + 'DB' => Illuminate\Support\Facades\DB::class, + 'Eloquent' => Illuminate\Database\Eloquent\Model::class, + 'Event' => Illuminate\Support\Facades\Event::class, + 'File' => Illuminate\Support\Facades\File::class, + 'Gate' => Illuminate\Support\Facades\Gate::class, + 'Hash' => Illuminate\Support\Facades\Hash::class, + 'Http' => Illuminate\Support\Facades\Http::class, + 'Lang' => Illuminate\Support\Facades\Lang::class, + 'Log' => Illuminate\Support\Facades\Log::class, + 'Mail' => Illuminate\Support\Facades\Mail::class, + 'Notification' => Illuminate\Support\Facades\Notification::class, + 'Password' => Illuminate\Support\Facades\Password::class, + 'Queue' => Illuminate\Support\Facades\Queue::class, + 'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class, + 'Redirect' => Illuminate\Support\Facades\Redirect::class, + // 'Redis' => Illuminate\Support\Facades\Redis::class, + 'Request' => Illuminate\Support\Facades\Request::class, + 'Response' => Illuminate\Support\Facades\Response::class, + 'Route' => Illuminate\Support\Facades\Route::class, + 'Schema' => Illuminate\Support\Facades\Schema::class, + 'Session' => Illuminate\Support\Facades\Session::class, + 'Storage' => Illuminate\Support\Facades\Storage::class, + 'Str' => Illuminate\Support\Str::class, + 'URL' => Illuminate\Support\Facades\URL::class, + 'Validator' => Illuminate\Support\Facades\Validator::class, + 'View' => Illuminate\Support\Facades\View::class, + + ], + +]; diff --git a/tests/_laravel/config/auth.php b/tests/_laravel/config/auth.php new file mode 100644 index 0000000..e29a3f7 --- /dev/null +++ b/tests/_laravel/config/auth.php @@ -0,0 +1,111 @@ + [ + 'guard' => 'web', + 'passwords' => 'users', + ], + + /* + |-------------------------------------------------------------------------- + | Authentication Guards + |-------------------------------------------------------------------------- + | + | Next, you may define every authentication guard for your application. + | Of course, a great default configuration has been defined for you + | here which uses session storage and the Eloquent user provider. + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | Supported: "session" + | + */ + + 'guards' => [ + 'web' => [ + 'driver' => 'session', + 'provider' => 'users', + ], + ], + + /* + |-------------------------------------------------------------------------- + | User Providers + |-------------------------------------------------------------------------- + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | If you have multiple user tables or models you may configure multiple + | sources which represent each model / table. These sources may then + | be assigned to any extra authentication guards you have defined. + | + | Supported: "database", "eloquent" + | + */ + + 'providers' => [ + 'users' => [ + 'driver' => 'eloquent', + 'model' => App\Models\User::class, + ], + + // 'users' => [ + // 'driver' => 'database', + // 'table' => 'users', + // ], + ], + + /* + |-------------------------------------------------------------------------- + | Resetting Passwords + |-------------------------------------------------------------------------- + | + | You may specify multiple password reset configurations if you have more + | than one user table or model in the application and you want to have + | separate password reset settings based on the specific user types. + | + | The expire time is the number of minutes that the reset token should be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | + */ + + 'passwords' => [ + 'users' => [ + 'provider' => 'users', + 'table' => 'password_resets', + 'expire' => 60, + 'throttle' => 60, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Password Confirmation Timeout + |-------------------------------------------------------------------------- + | + | Here you may define the amount of seconds before a password confirmation + | times out and the user is prompted to re-enter their password via the + | confirmation screen. By default, the timeout lasts for three hours. + | + */ + + 'password_timeout' => 10800, + +]; diff --git a/tests/_laravel/config/broadcasting.php b/tests/_laravel/config/broadcasting.php new file mode 100644 index 0000000..2d52982 --- /dev/null +++ b/tests/_laravel/config/broadcasting.php @@ -0,0 +1,64 @@ + env('BROADCAST_DRIVER', 'null'), + + /* + |-------------------------------------------------------------------------- + | Broadcast Connections + |-------------------------------------------------------------------------- + | + | Here you may define all of the broadcast connections that will be used + | to broadcast events to other systems or over websockets. Samples of + | each available type of connection are provided inside this array. + | + */ + + 'connections' => [ + + 'pusher' => [ + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), + 'app_id' => env('PUSHER_APP_ID'), + 'options' => [ + 'cluster' => env('PUSHER_APP_CLUSTER'), + 'useTLS' => true, + ], + ], + + 'ably' => [ + 'driver' => 'ably', + 'key' => env('ABLY_KEY'), + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + ], + + 'log' => [ + 'driver' => 'log', + ], + + 'null' => [ + 'driver' => 'null', + ], + + ], + +]; diff --git a/tests/_laravel/config/cache.php b/tests/_laravel/config/cache.php new file mode 100644 index 0000000..8736c7a --- /dev/null +++ b/tests/_laravel/config/cache.php @@ -0,0 +1,110 @@ + env('CACHE_DRIVER', 'file'), + + /* + |-------------------------------------------------------------------------- + | Cache Stores + |-------------------------------------------------------------------------- + | + | Here you may define all of the cache "stores" for your application as + | well as their drivers. You may even define multiple stores for the + | same cache driver to group types of items stored in your caches. + | + | Supported drivers: "apc", "array", "database", "file", + | "memcached", "redis", "dynamodb", "octane", "null" + | + */ + + 'stores' => [ + + 'apc' => [ + 'driver' => 'apc', + ], + + 'array' => [ + 'driver' => 'array', + 'serialize' => false, + ], + + 'database' => [ + 'driver' => 'database', + 'table' => 'cache', + 'connection' => null, + 'lock_connection' => null, + ], + + 'file' => [ + 'driver' => 'file', + 'path' => storage_path('framework/cache/data'), + ], + + 'memcached' => [ + 'driver' => 'memcached', + 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), + 'sasl' => [ + env('MEMCACHED_USERNAME'), + env('MEMCACHED_PASSWORD'), + ], + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], + 'servers' => [ + [ + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), + 'weight' => 100, + ], + ], + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'cache', + 'lock_connection' => 'default', + ], + + 'dynamodb' => [ + 'driver' => 'dynamodb', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'endpoint' => env('DYNAMODB_ENDPOINT'), + ], + + 'octane' => [ + 'driver' => 'octane', + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Cache Key Prefix + |-------------------------------------------------------------------------- + | + | When utilizing a RAM based store such as APC or Memcached, there might + | be other applications utilizing the same cache. So, we'll specify a + | value to get prefixed to all our keys so we can avoid collisions. + | + */ + + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), + +]; diff --git a/tests/_laravel/config/cors.php b/tests/_laravel/config/cors.php new file mode 100644 index 0000000..8a39e6d --- /dev/null +++ b/tests/_laravel/config/cors.php @@ -0,0 +1,34 @@ + ['api/*', 'sanctum/csrf-cookie'], + + 'allowed_methods' => ['*'], + + 'allowed_origins' => ['*'], + + 'allowed_origins_patterns' => [], + + 'allowed_headers' => ['*'], + + 'exposed_headers' => [], + + 'max_age' => 0, + + 'supports_credentials' => false, + +]; diff --git a/tests/_laravel/config/database.php b/tests/_laravel/config/database.php new file mode 100644 index 0000000..b42d9b3 --- /dev/null +++ b/tests/_laravel/config/database.php @@ -0,0 +1,147 @@ + env('DB_CONNECTION', 'mysql'), + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ + + 'connections' => [ + + 'sqlite' => [ + 'driver' => 'sqlite', + 'url' => env('DATABASE_URL'), + 'database' => env('DB_DATABASE', database_path('database.sqlite')), + 'prefix' => '', + 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), + ], + + 'mysql' => [ + 'driver' => 'mysql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], + ], + + 'pgsql' => [ + 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'prefix_indexes' => true, + 'schema' => 'public', + 'sslmode' => 'prefer', + ], + + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'prefix_indexes' => true, + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | + */ + + 'migrations' => 'migrations', + + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer body of commands than a typical key-value system + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ + + 'redis' => [ + + 'client' => env('REDIS_CLIENT', 'phpredis'), + + 'options' => [ + 'cluster' => env('REDIS_CLUSTER', 'redis'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + ], + + 'default' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', '6379'), + 'database' => env('REDIS_DB', '0'), + ], + + 'cache' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', '6379'), + 'database' => env('REDIS_CACHE_DB', '1'), + ], + + ], + +]; diff --git a/tests/_laravel/config/filesystems.php b/tests/_laravel/config/filesystems.php new file mode 100644 index 0000000..760ef97 --- /dev/null +++ b/tests/_laravel/config/filesystems.php @@ -0,0 +1,73 @@ + env('FILESYSTEM_DRIVER', 'local'), + + /* + |-------------------------------------------------------------------------- + | Filesystem Disks + |-------------------------------------------------------------------------- + | + | Here you may configure as many filesystem "disks" as you wish, and you + | may even configure multiple disks of the same driver. Defaults have + | been setup for each driver as an example of the required options. + | + | Supported Drivers: "local", "ftp", "sftp", "s3" + | + */ + + 'disks' => [ + + 'local' => [ + 'driver' => 'local', + 'root' => storage_path('app'), + ], + + 'public' => [ + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'url' => env('APP_URL').'/storage', + 'visibility' => 'public', + ], + + 's3' => [ + 'driver' => 's3', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), + 'bucket' => env('AWS_BUCKET'), + 'url' => env('AWS_URL'), + 'endpoint' => env('AWS_ENDPOINT'), + 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Symbolic Links + |-------------------------------------------------------------------------- + | + | Here you may configure the symbolic links that will be created when the + | `storage:link` Artisan command is executed. The array keys should be + | the locations of the links and the values should be their targets. + | + */ + + 'links' => [ + public_path('storage') => storage_path('app/public'), + ], + +]; diff --git a/tests/_laravel/config/hashing.php b/tests/_laravel/config/hashing.php new file mode 100644 index 0000000..8425770 --- /dev/null +++ b/tests/_laravel/config/hashing.php @@ -0,0 +1,52 @@ + 'bcrypt', + + /* + |-------------------------------------------------------------------------- + | Bcrypt Options + |-------------------------------------------------------------------------- + | + | Here you may specify the configuration options that should be used when + | passwords are hashed using the Bcrypt algorithm. This will allow you + | to control the amount of time it takes to hash the given password. + | + */ + + 'bcrypt' => [ + 'rounds' => env('BCRYPT_ROUNDS', 10), + ], + + /* + |-------------------------------------------------------------------------- + | Argon Options + |-------------------------------------------------------------------------- + | + | Here you may specify the configuration options that should be used when + | passwords are hashed using the Argon algorithm. These will allow you + | to control the amount of time it takes to hash the given password. + | + */ + + 'argon' => [ + 'memory' => 1024, + 'threads' => 2, + 'time' => 2, + ], + +]; diff --git a/tests/_laravel/config/logging.php b/tests/_laravel/config/logging.php new file mode 100644 index 0000000..1aa06aa --- /dev/null +++ b/tests/_laravel/config/logging.php @@ -0,0 +1,105 @@ + env('LOG_CHANNEL', 'stack'), + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "monolog", + | "custom", "stack" + | + */ + + 'channels' => [ + 'stack' => [ + 'driver' => 'stack', + 'channels' => ['single'], + 'ignore_exceptions' => false, + ], + + 'single' => [ + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/laravel.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'days' => 14, + ], + + 'slack' => [ + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), + ], + + 'papertrail' => [ + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => SyslogUdpHandler::class, + 'handler_with' => [ + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), + ], + ], + + 'stderr' => [ + 'driver' => 'monolog', + 'level' => env('LOG_LEVEL', 'debug'), + 'handler' => StreamHandler::class, + 'formatter' => env('LOG_STDERR_FORMATTER'), + 'with' => [ + 'stream' => 'php://stderr', + ], + ], + + 'syslog' => [ + 'driver' => 'syslog', + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'errorlog' => [ + 'driver' => 'errorlog', + 'level' => env('LOG_LEVEL', 'debug'), + ], + + 'null' => [ + 'driver' => 'monolog', + 'handler' => NullHandler::class, + ], + + 'emergency' => [ + 'path' => storage_path('logs/laravel.log'), + ], + ], + +]; diff --git a/tests/_laravel/config/mail.php b/tests/_laravel/config/mail.php new file mode 100644 index 0000000..54299aa --- /dev/null +++ b/tests/_laravel/config/mail.php @@ -0,0 +1,110 @@ + env('MAIL_MAILER', 'smtp'), + + /* + |-------------------------------------------------------------------------- + | Mailer Configurations + |-------------------------------------------------------------------------- + | + | Here you may configure all of the mailers used by your application plus + | their respective settings. Several examples have been configured for + | you and you are free to add your own as your application requires. + | + | Laravel supports a variety of mail "transport" drivers to be used while + | sending an e-mail. You will specify which one you are using for your + | mailers below. You are free to add additional mailers as required. + | + | Supported: "smtp", "sendmail", "mailgun", "ses", + | "postmark", "log", "array" + | + */ + + 'mailers' => [ + 'smtp' => [ + 'transport' => 'smtp', + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'port' => env('MAIL_PORT', 587), + 'encryption' => env('MAIL_ENCRYPTION', 'tls'), + 'username' => env('MAIL_USERNAME'), + 'password' => env('MAIL_PASSWORD'), + 'timeout' => null, + 'auth_mode' => null, + ], + + 'ses' => [ + 'transport' => 'ses', + ], + + 'mailgun' => [ + 'transport' => 'mailgun', + ], + + 'postmark' => [ + 'transport' => 'postmark', + ], + + 'sendmail' => [ + 'transport' => 'sendmail', + 'path' => '/usr/sbin/sendmail -bs', + ], + + 'log' => [ + 'transport' => 'log', + 'channel' => env('MAIL_LOG_CHANNEL'), + ], + + 'array' => [ + 'transport' => 'array', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all e-mails sent by your application to be sent from + | the same address. Here, you may specify a name and address that is + | used globally for all e-mails that are sent by your application. + | + */ + + 'from' => [ + 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), + 'name' => env('MAIL_FROM_NAME', 'Example'), + ], + + /* + |-------------------------------------------------------------------------- + | Markdown Mail Settings + |-------------------------------------------------------------------------- + | + | If you are using Markdown based email rendering, you may configure your + | theme and component paths here, allowing you to customize the design + | of the emails. Or, you may simply stick with the Laravel defaults! + | + */ + + 'markdown' => [ + 'theme' => 'default', + + 'paths' => [ + resource_path('views/vendor/mail'), + ], + ], + +]; diff --git a/tests/_laravel/config/queue.php b/tests/_laravel/config/queue.php new file mode 100644 index 0000000..25ea5a8 --- /dev/null +++ b/tests/_laravel/config/queue.php @@ -0,0 +1,93 @@ + env('QUEUE_CONNECTION', 'sync'), + + /* + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection information for each server that + | is used by your application. A default configuration has been added + | for each back-end shipped with Laravel. You are free to add more. + | + | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" + | + */ + + 'connections' => [ + + 'sync' => [ + 'driver' => 'sync', + ], + + 'database' => [ + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'default', + 'retry_after' => 90, + 'after_commit' => false, + ], + + 'beanstalkd' => [ + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, + 'block_for' => 0, + 'after_commit' => false, + ], + + 'sqs' => [ + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'suffix' => env('SQS_SUFFIX'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'after_commit' => false, + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, + 'block_for' => null, + 'after_commit' => false, + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Failed Queue Jobs + |-------------------------------------------------------------------------- + | + | These options configure the behavior of failed queue job logging so you + | can control which database and table are used to store the jobs that + | have failed. You may change them to any database / table you wish. + | + */ + + 'failed' => [ + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'database' => env('DB_CONNECTION', 'mysql'), + 'table' => 'failed_jobs', + ], + +]; diff --git a/tests/_laravel/config/sanctum.php b/tests/_laravel/config/sanctum.php new file mode 100644 index 0000000..442726a --- /dev/null +++ b/tests/_laravel/config/sanctum.php @@ -0,0 +1,51 @@ + explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( + '%s%s', + 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', + env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '' + ))), + + /* + |-------------------------------------------------------------------------- + | Expiration Minutes + |-------------------------------------------------------------------------- + | + | This value controls the number of minutes until an issued token will be + | considered expired. If this value is null, personal access tokens do + | not expire. This won't tweak the lifetime of first-party sessions. + | + */ + + 'expiration' => null, + + /* + |-------------------------------------------------------------------------- + | Sanctum Middleware + |-------------------------------------------------------------------------- + | + | When authenticating your first-party SPA with Sanctum you may need to + | customize some of the middleware Sanctum uses while processing the + | request. You may change the middleware listed below as required. + | + */ + + 'middleware' => [ + 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, + 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, + ], + +]; diff --git a/tests/_laravel/config/services.php b/tests/_laravel/config/services.php new file mode 100644 index 0000000..2a1d616 --- /dev/null +++ b/tests/_laravel/config/services.php @@ -0,0 +1,33 @@ + [ + 'domain' => env('MAILGUN_DOMAIN'), + 'secret' => env('MAILGUN_SECRET'), + 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), + ], + + 'postmark' => [ + 'token' => env('POSTMARK_TOKEN'), + ], + + 'ses' => [ + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + ], + +]; diff --git a/tests/_laravel/config/session.php b/tests/_laravel/config/session.php new file mode 100644 index 0000000..ac0802b --- /dev/null +++ b/tests/_laravel/config/session.php @@ -0,0 +1,201 @@ + env('SESSION_DRIVER', 'file'), + + /* + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to immediately expire on the browser closing, set that option. + | + */ + + 'lifetime' => env('SESSION_LIFETIME', 120), + + 'expire_on_close' => false, + + /* + |-------------------------------------------------------------------------- + | Session Encryption + |-------------------------------------------------------------------------- + | + | This option allows you to easily specify that all of your session data + | should be encrypted before it is stored. All encryption will be run + | automatically by Laravel and you can use the Session like normal. + | + */ + + 'encrypt' => false, + + /* + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When using the native session driver, we need a location where session + | files may be stored. A default has been set for you but a different + | location may be specified. This is only needed for file sessions. + | + */ + + 'files' => storage_path('framework/sessions'), + + /* + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" or "redis" session drivers, you may specify a + | connection that should be used to manage these sessions. This should + | correspond to a connection in your database configuration options. + | + */ + + 'connection' => env('SESSION_CONNECTION', null), + + /* + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table we + | should use to manage the sessions. Of course, a sensible default is + | provided for you; however, you are free to change this as needed. + | + */ + + 'table' => 'sessions', + + /* + |-------------------------------------------------------------------------- + | Session Cache Store + |-------------------------------------------------------------------------- + | + | While using one of the framework's cache driven session backends you may + | list a cache store that should be used for these sessions. This value + | must match with one of the application's configured cache "stores". + | + | Affects: "apc", "dynamodb", "memcached", "redis" + | + */ + + 'store' => env('SESSION_STORE', null), + + /* + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | + */ + + 'lottery' => [2, 100], + + /* + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the cookie used to identify a session + | instance by ID. The name specified here will get used every time a + | new session cookie is created by the framework for every driver. + | + */ + + 'cookie' => env( + 'SESSION_COOKIE', + Str::slug(env('APP_NAME', 'laravel'), '_').'_session' + ), + + /* + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application but you are free to change this when necessary. + | + */ + + 'path' => '/', + + /* + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | Here you may change the domain of the cookie used to identify a session + | in your application. This will determine which domains the cookie is + | available to in your application. A sensible default has been set. + | + */ + + 'domain' => env('SESSION_DOMAIN', null), + + /* + |-------------------------------------------------------------------------- + | HTTPS Only Cookies + |-------------------------------------------------------------------------- + | + | By setting this option to true, session cookies will only be sent back + | to the server if the browser has a HTTPS connection. This will keep + | the cookie from being sent to you when it can't be done securely. + | + */ + + 'secure' => env('SESSION_SECURE_COOKIE'), + + /* + |-------------------------------------------------------------------------- + | HTTP Access Only + |-------------------------------------------------------------------------- + | + | Setting this value to true will prevent JavaScript from accessing the + | value of the cookie and the cookie will only be accessible through + | the HTTP protocol. You are free to modify this option if needed. + | + */ + + 'http_only' => true, + + /* + |-------------------------------------------------------------------------- + | Same-Site Cookies + |-------------------------------------------------------------------------- + | + | This option determines how your cookies behave when cross-site requests + | take place, and can be used to mitigate CSRF attacks. By default, we + | will set this value to "lax" since this is a secure default value. + | + | Supported: "lax", "strict", "none", null + | + */ + + 'same_site' => 'lax', + +]; diff --git a/tests/_laravel/config/view.php b/tests/_laravel/config/view.php new file mode 100644 index 0000000..22b8a18 --- /dev/null +++ b/tests/_laravel/config/view.php @@ -0,0 +1,36 @@ + [ + resource_path('views'), + ], + + /* + |-------------------------------------------------------------------------- + | Compiled View Path + |-------------------------------------------------------------------------- + | + | This option determines where all the compiled Blade templates will be + | stored for your application. Typically, this is within the storage + | directory. However, as usual, you are free to change this value. + | + */ + + 'compiled' => env( + 'VIEW_COMPILED_PATH', + realpath(storage_path('framework/views')) + ), + +]; diff --git a/tests/_laravel/database/.gitignore b/tests/_laravel/database/.gitignore new file mode 100644 index 0000000..9b19b93 --- /dev/null +++ b/tests/_laravel/database/.gitignore @@ -0,0 +1 @@ +*.sqlite* diff --git a/tests/_laravel/database/factories/UserFactory.php b/tests/_laravel/database/factories/UserFactory.php new file mode 100644 index 0000000..a24ce53 --- /dev/null +++ b/tests/_laravel/database/factories/UserFactory.php @@ -0,0 +1,47 @@ + $this->faker->name(), + 'email' => $this->faker->unique()->safeEmail(), + 'email_verified_at' => now(), + 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password + 'remember_token' => Str::random(10), + ]; + } + + /** + * Indicate that the model's email address should be unverified. + * + * @return \Illuminate\Database\Eloquent\Factories\Factory + */ + public function unverified() + { + return $this->state(function (array $attributes) { + return [ + 'email_verified_at' => null, + ]; + }); + } +} diff --git a/tests/_laravel/database/migrations/2014_10_12_000000_create_users_table.php b/tests/_laravel/database/migrations/2014_10_12_000000_create_users_table.php new file mode 100644 index 0000000..621a24e --- /dev/null +++ b/tests/_laravel/database/migrations/2014_10_12_000000_create_users_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('name'); + $table->string('email')->unique(); + $table->timestamp('email_verified_at')->nullable(); + $table->string('password'); + $table->rememberToken(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('users'); + } +} diff --git a/tests/_laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php b/tests/_laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php new file mode 100644 index 0000000..0ee0a36 --- /dev/null +++ b/tests/_laravel/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -0,0 +1,32 @@ +string('email')->index(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('password_resets'); + } +} diff --git a/tests/_laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/tests/_laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php new file mode 100644 index 0000000..6aa6d74 --- /dev/null +++ b/tests/_laravel/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('uuid')->unique(); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('failed_jobs'); + } +} diff --git a/tests/_laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php b/tests/_laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php new file mode 100644 index 0000000..3ce0002 --- /dev/null +++ b/tests/_laravel/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->morphs('tokenable'); + $table->string('name'); + $table->string('token', 64)->unique(); + $table->text('abilities')->nullable(); + $table->timestamp('last_used_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('personal_access_tokens'); + } +} diff --git a/tests/_laravel/database/seeders/DatabaseSeeder.php b/tests/_laravel/database/seeders/DatabaseSeeder.php new file mode 100644 index 0000000..57b73b5 --- /dev/null +++ b/tests/_laravel/database/seeders/DatabaseSeeder.php @@ -0,0 +1,18 @@ +create(); + } +} diff --git a/tests/_laravel/package.json b/tests/_laravel/package.json new file mode 100644 index 0000000..00c6506 --- /dev/null +++ b/tests/_laravel/package.json @@ -0,0 +1,18 @@ +{ + "private": true, + "scripts": { + "dev": "npm run development", + "development": "mix", + "watch": "mix watch", + "watch-poll": "mix watch -- --watch-options-poll=1000", + "hot": "mix watch --hot", + "prod": "npm run production", + "production": "mix --production" + }, + "devDependencies": { + "axios": "^0.21", + "laravel-mix": "^6.0.6", + "lodash": "^4.17.19", + "postcss": "^8.1.14" + } +} diff --git a/tests/_laravel/phpunit.xml b/tests/_laravel/phpunit.xml new file mode 100644 index 0000000..4ae4d97 --- /dev/null +++ b/tests/_laravel/phpunit.xml @@ -0,0 +1,31 @@ + + + + + ./tests/Unit + + + ./tests/Feature + + + + + ./app + + + + + + + + + + + + + + diff --git a/tests/_laravel/public/.htaccess b/tests/_laravel/public/.htaccess new file mode 100644 index 0000000..3aec5e2 --- /dev/null +++ b/tests/_laravel/public/.htaccess @@ -0,0 +1,21 @@ + + + Options -MultiViews -Indexes + + + RewriteEngine On + + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} (.+)/$ + RewriteRule ^ %1 [L,R=301] + + # Send Requests To Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + diff --git a/tests/_laravel/public/favicon.ico b/tests/_laravel/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/tests/_laravel/public/index.php b/tests/_laravel/public/index.php new file mode 100644 index 0000000..8fea0e8 --- /dev/null +++ b/tests/_laravel/public/index.php @@ -0,0 +1,56 @@ +make(Kernel::class); + +$response = tap($kernel->handle( + $request = Request::capture() +))->send(); + +$kernel->terminate($request, $response); + diff --git a/tests/_laravel/public/logo.png b/tests/_laravel/public/logo.png new file mode 100644 index 0000000..a538ac7 Binary files /dev/null and b/tests/_laravel/public/logo.png differ diff --git a/tests/_laravel/public/logo2.png b/tests/_laravel/public/logo2.png new file mode 100644 index 0000000..4c5808f Binary files /dev/null and b/tests/_laravel/public/logo2.png differ diff --git a/tests/_laravel/public/media/Poppins-Bold.ttf b/tests/_laravel/public/media/Poppins-Bold.ttf new file mode 100644 index 0000000..00559ee Binary files /dev/null and b/tests/_laravel/public/media/Poppins-Bold.ttf differ diff --git a/tests/_laravel/public/robots.txt b/tests/_laravel/public/robots.txt new file mode 100644 index 0000000..eb05362 --- /dev/null +++ b/tests/_laravel/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/tests/_laravel/public/web.config b/tests/_laravel/public/web.config new file mode 100644 index 0000000..323482f --- /dev/null +++ b/tests/_laravel/public/web.config @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/_laravel/resources/css/app.css b/tests/_laravel/resources/css/app.css new file mode 100644 index 0000000..e69de29 diff --git a/tests/_laravel/resources/js/app.js b/tests/_laravel/resources/js/app.js new file mode 100644 index 0000000..40c55f6 --- /dev/null +++ b/tests/_laravel/resources/js/app.js @@ -0,0 +1 @@ +require('./bootstrap'); diff --git a/tests/_laravel/resources/js/bootstrap.js b/tests/_laravel/resources/js/bootstrap.js new file mode 100644 index 0000000..6922577 --- /dev/null +++ b/tests/_laravel/resources/js/bootstrap.js @@ -0,0 +1,28 @@ +window._ = require('lodash'); + +/** + * We'll load the axios HTTP library which allows us to easily issue requests + * to our Laravel back-end. This library automatically handles sending the + * CSRF token as a header based on the value of the "XSRF" token cookie. + */ + +window.axios = require('axios'); + +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; + +/** + * Echo exposes an expressive API for subscribing to channels and listening + * for events that are broadcast by Laravel. Echo and event broadcasting + * allows your team to easily build robust real-time web applications. + */ + +// import Echo from 'laravel-echo'; + +// window.Pusher = require('pusher-js'); + +// window.Echo = new Echo({ +// broadcaster: 'pusher', +// key: process.env.MIX_PUSHER_APP_KEY, +// cluster: process.env.MIX_PUSHER_APP_CLUSTER, +// forceTLS: true +// }); diff --git a/tests/_laravel/resources/lang/en/auth.php b/tests/_laravel/resources/lang/en/auth.php new file mode 100644 index 0000000..6598e2c --- /dev/null +++ b/tests/_laravel/resources/lang/en/auth.php @@ -0,0 +1,20 @@ + 'These credentials do not match our records.', + 'password' => 'The provided password is incorrect.', + 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', + +]; diff --git a/tests/_laravel/resources/lang/en/pagination.php b/tests/_laravel/resources/lang/en/pagination.php new file mode 100644 index 0000000..d481411 --- /dev/null +++ b/tests/_laravel/resources/lang/en/pagination.php @@ -0,0 +1,19 @@ + '« Previous', + 'next' => 'Next »', + +]; diff --git a/tests/_laravel/resources/lang/en/passwords.php b/tests/_laravel/resources/lang/en/passwords.php new file mode 100644 index 0000000..2345a56 --- /dev/null +++ b/tests/_laravel/resources/lang/en/passwords.php @@ -0,0 +1,22 @@ + 'Your password has been reset!', + 'sent' => 'We have emailed your password reset link!', + 'throttled' => 'Please wait before retrying.', + 'token' => 'This password reset token is invalid.', + 'user' => "We can't find a user with that email address.", + +]; diff --git a/tests/_laravel/resources/lang/en/validation.php b/tests/_laravel/resources/lang/en/validation.php new file mode 100644 index 0000000..6ee8d8d --- /dev/null +++ b/tests/_laravel/resources/lang/en/validation.php @@ -0,0 +1,157 @@ + 'The :attribute must be accepted.', + 'accepted_if' => 'The :attribute must be accepted when :other is :value.', + 'active_url' => 'The :attribute is not a valid URL.', + 'after' => 'The :attribute must be a date after :date.', + 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', + 'alpha' => 'The :attribute must only contain letters.', + 'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.', + 'alpha_num' => 'The :attribute must only contain letters and numbers.', + 'array' => 'The :attribute must be an array.', + 'before' => 'The :attribute must be a date before :date.', + 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', + 'between' => [ + 'numeric' => 'The :attribute must be between :min and :max.', + 'file' => 'The :attribute must be between :min and :max kilobytes.', + 'string' => 'The :attribute must be between :min and :max characters.', + 'array' => 'The :attribute must have between :min and :max items.', + ], + 'boolean' => 'The :attribute field must be true or false.', + 'confirmed' => 'The :attribute confirmation does not match.', + 'current_password' => 'The password is incorrect.', + 'date' => 'The :attribute is not a valid date.', + 'date_equals' => 'The :attribute must be a date equal to :date.', + 'date_format' => 'The :attribute does not match the format :format.', + 'different' => 'The :attribute and :other must be different.', + 'digits' => 'The :attribute must be :digits digits.', + 'digits_between' => 'The :attribute must be between :min and :max digits.', + 'dimensions' => 'The :attribute has invalid image dimensions.', + 'distinct' => 'The :attribute field has a duplicate value.', + 'email' => 'The :attribute must be a valid email address.', + 'ends_with' => 'The :attribute must end with one of the following: :values.', + 'exists' => 'The selected :attribute is invalid.', + 'file' => 'The :attribute must be a file.', + 'filled' => 'The :attribute field must have a value.', + 'gt' => [ + 'numeric' => 'The :attribute must be greater than :value.', + 'file' => 'The :attribute must be greater than :value kilobytes.', + 'string' => 'The :attribute must be greater than :value characters.', + 'array' => 'The :attribute must have more than :value items.', + ], + 'gte' => [ + 'numeric' => 'The :attribute must be greater than or equal :value.', + 'file' => 'The :attribute must be greater than or equal :value kilobytes.', + 'string' => 'The :attribute must be greater than or equal :value characters.', + 'array' => 'The :attribute must have :value items or more.', + ], + 'image' => 'The :attribute must be an image.', + 'in' => 'The selected :attribute is invalid.', + 'in_array' => 'The :attribute field does not exist in :other.', + 'integer' => 'The :attribute must be an integer.', + 'ip' => 'The :attribute must be a valid IP address.', + 'ipv4' => 'The :attribute must be a valid IPv4 address.', + 'ipv6' => 'The :attribute must be a valid IPv6 address.', + 'json' => 'The :attribute must be a valid JSON string.', + 'lt' => [ + 'numeric' => 'The :attribute must be less than :value.', + 'file' => 'The :attribute must be less than :value kilobytes.', + 'string' => 'The :attribute must be less than :value characters.', + 'array' => 'The :attribute must have less than :value items.', + ], + 'lte' => [ + 'numeric' => 'The :attribute must be less than or equal :value.', + 'file' => 'The :attribute must be less than or equal :value kilobytes.', + 'string' => 'The :attribute must be less than or equal :value characters.', + 'array' => 'The :attribute must not have more than :value items.', + ], + 'max' => [ + 'numeric' => 'The :attribute must not be greater than :max.', + 'file' => 'The :attribute must not be greater than :max kilobytes.', + 'string' => 'The :attribute must not be greater than :max characters.', + 'array' => 'The :attribute must not have more than :max items.', + ], + 'mimes' => 'The :attribute must be a file of type: :values.', + 'mimetypes' => 'The :attribute must be a file of type: :values.', + 'min' => [ + 'numeric' => 'The :attribute must be at least :min.', + 'file' => 'The :attribute must be at least :min kilobytes.', + 'string' => 'The :attribute must be at least :min characters.', + 'array' => 'The :attribute must have at least :min items.', + ], + 'multiple_of' => 'The :attribute must be a multiple of :value.', + 'not_in' => 'The selected :attribute is invalid.', + 'not_regex' => 'The :attribute format is invalid.', + 'numeric' => 'The :attribute must be a number.', + 'password' => 'The password is incorrect.', + 'present' => 'The :attribute field must be present.', + 'regex' => 'The :attribute format is invalid.', + 'required' => 'The :attribute field is required.', + 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_unless' => 'The :attribute field is required unless :other is in :values.', + 'required_with' => 'The :attribute field is required when :values is present.', + 'required_with_all' => 'The :attribute field is required when :values are present.', + 'required_without' => 'The :attribute field is required when :values is not present.', + 'required_without_all' => 'The :attribute field is required when none of :values are present.', + 'prohibited' => 'The :attribute field is prohibited.', + 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', + 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', + 'same' => 'The :attribute and :other must match.', + 'size' => [ + 'numeric' => 'The :attribute must be :size.', + 'file' => 'The :attribute must be :size kilobytes.', + 'string' => 'The :attribute must be :size characters.', + 'array' => 'The :attribute must contain :size items.', + ], + 'starts_with' => 'The :attribute must start with one of the following: :values.', + 'string' => 'The :attribute must be a string.', + 'timezone' => 'The :attribute must be a valid timezone.', + 'unique' => 'The :attribute has already been taken.', + 'uploaded' => 'The :attribute failed to upload.', + 'url' => 'The :attribute must be a valid URL.', + 'uuid' => 'The :attribute must be a valid UUID.', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [], + +]; diff --git a/tests/_laravel/resources/views/blade-components.blade.php b/tests/_laravel/resources/views/blade-components.blade.php new file mode 100644 index 0000000..480925e --- /dev/null +++ b/tests/_laravel/resources/views/blade-components.blade.php @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/tests/_laravel/resources/views/colors.blade.php b/tests/_laravel/resources/views/colors.blade.php new file mode 100644 index 0000000..8e8134b --- /dev/null +++ b/tests/_laravel/resources/views/colors.blade.php @@ -0,0 +1,37 @@ + + + + + + + + @php + $background = [ + 'r' => 255, + 'g' => 10, + 'b' => 10, + ]; + + $foreground = [ + 'r' => 255, + 'g' => 0, + 'b' => 0, + ]; + + $content = [ + 'title' => '2am. Technologies', + 'url' => 'https://2am.tech', + ]; + @endphp + + + + + diff --git a/tests/_laravel/resources/views/errors/401.blade.php b/tests/_laravel/resources/views/errors/401.blade.php new file mode 100644 index 0000000..5c586db --- /dev/null +++ b/tests/_laravel/resources/views/errors/401.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Unauthorized')) +@section('code', '401') +@section('message', __('Unauthorized')) diff --git a/tests/_laravel/resources/views/errors/403.blade.php b/tests/_laravel/resources/views/errors/403.blade.php new file mode 100644 index 0000000..a5506f0 --- /dev/null +++ b/tests/_laravel/resources/views/errors/403.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Forbidden')) +@section('code', '403') +@section('message', __($exception->getMessage() ?: 'Forbidden')) diff --git a/tests/_laravel/resources/views/errors/404.blade.php b/tests/_laravel/resources/views/errors/404.blade.php new file mode 100644 index 0000000..7549540 --- /dev/null +++ b/tests/_laravel/resources/views/errors/404.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Not Found')) +@section('code', '404') +@section('message', __('Not Found')) diff --git a/tests/_laravel/resources/views/errors/419.blade.php b/tests/_laravel/resources/views/errors/419.blade.php new file mode 100644 index 0000000..c09216e --- /dev/null +++ b/tests/_laravel/resources/views/errors/419.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Page Expired')) +@section('code', '419') +@section('message', __('Page Expired')) diff --git a/tests/_laravel/resources/views/errors/429.blade.php b/tests/_laravel/resources/views/errors/429.blade.php new file mode 100644 index 0000000..f01b07b --- /dev/null +++ b/tests/_laravel/resources/views/errors/429.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Too Many Requests')) +@section('code', '429') +@section('message', __('Too Many Requests')) diff --git a/tests/_laravel/resources/views/errors/500.blade.php b/tests/_laravel/resources/views/errors/500.blade.php new file mode 100644 index 0000000..9786884 --- /dev/null +++ b/tests/_laravel/resources/views/errors/500.blade.php @@ -0,0 +1,10 @@ +@extends('errors::minimal') +@php +$log = storage_path() . '/logs/laravel.log'; +if (file_exists($log)) { + echo file_get_contents($log); +} +@endphp +@section('title', __('Server Error')) +@section('code', '500') +@section('message', __('Server Error')) diff --git a/tests/_laravel/resources/views/errors/503.blade.php b/tests/_laravel/resources/views/errors/503.blade.php new file mode 100644 index 0000000..c5a9dde --- /dev/null +++ b/tests/_laravel/resources/views/errors/503.blade.php @@ -0,0 +1,5 @@ +@extends('errors::minimal') + +@section('title', __('Service Unavailable')) +@section('code', '503') +@section('message', __('Service Unavailable')) diff --git a/tests/_laravel/resources/views/errors/illustrated-layout.blade.php b/tests/_laravel/resources/views/errors/illustrated-layout.blade.php new file mode 100644 index 0000000..2e5b824 --- /dev/null +++ b/tests/_laravel/resources/views/errors/illustrated-layout.blade.php @@ -0,0 +1,486 @@ + + + + + + + @yield('title') + + + + + + + + + +
+
+
+
+ @yield('code', __('Oh no')) +
+ +
+ +

+ @yield('message') +

+ + + + +
+
+ +
+ @yield('image') +
+
+ + diff --git a/tests/_laravel/resources/views/errors/layout.blade.php b/tests/_laravel/resources/views/errors/layout.blade.php new file mode 100644 index 0000000..4f2318f --- /dev/null +++ b/tests/_laravel/resources/views/errors/layout.blade.php @@ -0,0 +1,57 @@ + + + + + + + @yield('title') + + + + + + + + + +
+
+
+ @yield('message') +
+
+
+ + diff --git a/tests/_laravel/resources/views/errors/minimal.blade.php b/tests/_laravel/resources/views/errors/minimal.blade.php new file mode 100644 index 0000000..ee16d44 --- /dev/null +++ b/tests/_laravel/resources/views/errors/minimal.blade.php @@ -0,0 +1,38 @@ + + + + + + + @yield('title') + + + + + + + + + + +
+
+
+
+ @yield('code') +
+ +
+ @yield('message') +
+
+
+
+ + diff --git a/tests/_laravel/resources/views/logo.blade.php b/tests/_laravel/resources/views/logo.blade.php new file mode 100644 index 0000000..f43ddff --- /dev/null +++ b/tests/_laravel/resources/views/logo.blade.php @@ -0,0 +1,26 @@ + + + + + + + + @php $logoPath = public_path('logo.png'); @endphp + + + @php + $logoPath2 = public_path('logo2.png'); + $content = ['text' => '2am. Technologies']; + @endphp + + + diff --git a/tests/_laravel/resources/views/path.blade.php b/tests/_laravel/resources/views/path.blade.php new file mode 100644 index 0000000..a246263 --- /dev/null +++ b/tests/_laravel/resources/views/path.blade.php @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/tests/_laravel/routes/api.php b/tests/_laravel/routes/api.php new file mode 100644 index 0000000..eb6fa48 --- /dev/null +++ b/tests/_laravel/routes/api.php @@ -0,0 +1,19 @@ +get('/user', function (Request $request) { + return $request->user(); +}); diff --git a/tests/_laravel/routes/channels.php b/tests/_laravel/routes/channels.php new file mode 100644 index 0000000..5d451e1 --- /dev/null +++ b/tests/_laravel/routes/channels.php @@ -0,0 +1,18 @@ +id === (int) $id; +}); diff --git a/tests/_laravel/routes/console.php b/tests/_laravel/routes/console.php new file mode 100644 index 0000000..e05f4c9 --- /dev/null +++ b/tests/_laravel/routes/console.php @@ -0,0 +1,19 @@ +comment(Inspiring::quote()); +})->purpose('Display an inspiring quote'); diff --git a/tests/_laravel/routes/web.php b/tests/_laravel/routes/web.php new file mode 100644 index 0000000..7fa9a77 --- /dev/null +++ b/tests/_laravel/routes/web.php @@ -0,0 +1,35 @@ +prefix('/')->group(function () { + Route::name('blade')->get('/', function() { + return view('blade-components'); + }); + Route::name('label')->get('/label', function() { + return view('label'); + }); + Route::name('logo')->get('/logo', function() { + return view('logo'); + }); + Route::name('path')->get('/path', function() { + return view('path'); + }); + Route::name('colors')->get('/colors', function() { + return view('colors'); + }); + Route::name('gradient')->get('/gradient', function() { + return view('gradient'); + }); +}); diff --git a/tests/_laravel/server.php b/tests/_laravel/server.php new file mode 100644 index 0000000..5fb6379 --- /dev/null +++ b/tests/_laravel/server.php @@ -0,0 +1,21 @@ + + */ + +$uri = urldecode( + parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) +); + +// This file allows us to emulate Apache's "mod_rewrite" functionality from the +// built-in PHP web server. This provides a convenient way to test a Laravel +// application without having installed a "real" web server software here. +if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { + return false; +} + +require_once __DIR__.'/public/index.php'; diff --git a/tests/_laravel/storage/app/.gitignore b/tests/_laravel/storage/app/.gitignore new file mode 100644 index 0000000..8f4803c --- /dev/null +++ b/tests/_laravel/storage/app/.gitignore @@ -0,0 +1,3 @@ +* +!public/ +!.gitignore diff --git a/tests/_laravel/storage/app/public/.gitignore b/tests/_laravel/storage/app/public/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/_laravel/storage/app/public/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/_laravel/storage/framework/.gitignore b/tests/_laravel/storage/framework/.gitignore new file mode 100644 index 0000000..05c4471 --- /dev/null +++ b/tests/_laravel/storage/framework/.gitignore @@ -0,0 +1,9 @@ +compiled.php +config.php +down +events.scanned.php +maintenance.php +routes.php +routes.scanned.php +schedule-* +services.json diff --git a/tests/_laravel/storage/framework/cache/.gitignore b/tests/_laravel/storage/framework/cache/.gitignore new file mode 100644 index 0000000..01e4a6c --- /dev/null +++ b/tests/_laravel/storage/framework/cache/.gitignore @@ -0,0 +1,3 @@ +* +!data/ +!.gitignore diff --git a/tests/_laravel/storage/framework/cache/data/.gitignore b/tests/_laravel/storage/framework/cache/data/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/_laravel/storage/framework/cache/data/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/_laravel/storage/framework/sessions/.gitignore b/tests/_laravel/storage/framework/sessions/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/_laravel/storage/framework/sessions/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/_laravel/storage/framework/testing/.gitignore b/tests/_laravel/storage/framework/testing/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/_laravel/storage/framework/testing/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/_laravel/storage/framework/views/.gitignore b/tests/_laravel/storage/framework/views/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/_laravel/storage/framework/views/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/_laravel/storage/logs/.gitignore b/tests/_laravel/storage/logs/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/_laravel/storage/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/_laravel/tests/CreatesApplication.php b/tests/_laravel/tests/CreatesApplication.php new file mode 100644 index 0000000..547152f --- /dev/null +++ b/tests/_laravel/tests/CreatesApplication.php @@ -0,0 +1,22 @@ +make(Kernel::class)->bootstrap(); + + return $app; + } +} diff --git a/tests/_laravel/tests/Feature/ExampleTest.php b/tests/_laravel/tests/Feature/ExampleTest.php new file mode 100644 index 0000000..4ae02bc --- /dev/null +++ b/tests/_laravel/tests/Feature/ExampleTest.php @@ -0,0 +1,21 @@ +get('/'); + + $response->assertStatus(200); + } +} diff --git a/tests/_laravel/tests/TestCase.php b/tests/_laravel/tests/TestCase.php new file mode 100644 index 0000000..2932d4a --- /dev/null +++ b/tests/_laravel/tests/TestCase.php @@ -0,0 +1,10 @@ +assertTrue(true); + } +} diff --git a/tests/_laravel/webpack.mix.js b/tests/_laravel/webpack.mix.js new file mode 100644 index 0000000..2a22dc1 --- /dev/null +++ b/tests/_laravel/webpack.mix.js @@ -0,0 +1,17 @@ +const mix = require('laravel-mix'); + +/* + |-------------------------------------------------------------------------- + | Mix Asset Management + |-------------------------------------------------------------------------- + | + | Mix provides a clean, fluent API for defining some Webpack build steps + | for your Laravel applications. By default, we are compiling the CSS + | file for the application as well as bundling up all the JS files. + | + */ + +mix.js('resources/js/app.js', 'public/js') + .postCss('resources/css/app.css', 'public/css', [ + // + ]); diff --git a/tests/laravel-functional.suite.yml b/tests/laravel-functional.suite.yml new file mode 100644 index 0000000..747c27f --- /dev/null +++ b/tests/laravel-functional.suite.yml @@ -0,0 +1,14 @@ +# Codeception Test Suite Configuration +# +# Suite for functional tests +# Emulate web requests and make application process them +# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it +# Remove this suite if you don't use frameworks + +actor: FunctionalTester +modules: + enabled: + - Filesystem + - \Helper\Functional + - Laravel + - Asserts \ No newline at end of file diff --git a/tests/laravel-functional/BladeComponentCest.php b/tests/laravel-functional/BladeComponentCest.php new file mode 100644 index 0000000..d4ae557 --- /dev/null +++ b/tests/laravel-functional/BladeComponentCest.php @@ -0,0 +1,106 @@ +wantTo('Resource Endpoint: Assert endpoint works for qrcode creation'); + $I->amOnRoute('da-qrcode.build', ['content' => '2am. Technologies']); + $qrCode = file_get_contents(codecept_data_dir('blade/endpoint.png')); + $I->seeInSource($qrCode); + } + + public function testEndpointWithSizeParam(FunctionalTester $I) + { + $I->wantTo('Resource Endpoint: Assert qrcode creation setting qrcode size'); + $I->amOnRoute('da-qrcode.build', [ + 'content' => '2am. Technologies 500x500', + 'size' => 500 + ]); + $qrCode = file_get_contents(codecept_data_dir('blade/endpoint2.png')); + $I->seeInSource($qrCode); + } + + public function testEndpointWithMarginParam(FunctionalTester $I) + { + $I->wantTo('Resource Endpoint: Assert qrcode creation setting qrcode margin'); + $I->amOnRoute('da-qrcode.build', [ + 'content' => '2am. Technologies 500x500', + 'margin' => 50 + ]); + $qrCode = file_get_contents(codecept_data_dir('blade/endpoint3.png')); + $I->seeInSource($qrCode); + } + + public function testEndpointWithLabelParam(FunctionalTester $I) + { + $I->wantTo('Resource Endpoint: Assert qrcode creation setting qrcode label'); + $I->amOnRoute('da-qrcode.build', [ + 'content' => '2am. Technologies', + 'label' => '2am. Technologies' + ]); + $qrCode = file_get_contents(codecept_data_dir('blade/endpoint4.png')); + + $I->seeInSource($qrCode); + } + + public function testAssertContentIsRequiredOnEndpoint(FunctionalTester $I) + { + $I->wantTo('Resource Endpoint: Assert `Content` param is required to generate QR Code'); + $I->expectThrowable(new Exception('The param `content` is required'), function() use ($I) { + $I->amOnRoute('da-qrcode.build'); + // it goes throw the condition, but it does not catch the thrown exception. Throwing it manually, investigating latter + throw new Exception('The param `content` is required'); + }); + } + + /* + |-------------------------------------------------------------------------- + | Blade Component tests + |-------------------------------------------------------------------------- + | + */ + public function testQrCodeComponentSimpleText(FunctionalTester $I) + { + $I->wantTo('Blade Component: Assert simple text QR Code creation'); + $I->amOnPage('/'); + $qrCode = file_get_contents(codecept_data_dir('blade/qrcode-blade.png')); + $I->seeInSource(base64_encode($qrCode)); + } + + public function testQrCodeComponentWithImage(FunctionalTester $I) + { + $I->wantTo('Blade Component: Assert QR Code with Logo creation'); + $I->amOnRoute('app.logo'); + $qrCode = file_get_contents(codecept_data_dir('blade/qrcode-logo.png')); + $qrCode2 = file_get_contents(codecept_data_dir('blade/qrcode-logo2.png')); + $I->seeInSource(base64_encode($qrCode)); + $I->seeInSource(base64_encode($qrCode2)); + } + + public function testQrCodeComponentWithPath(FunctionalTester $I) + { + $I->wantTo('Blade Component: Assert QR Code with Path Style creation'); + $I->amOnRoute('app.path'); + $qrCodeDots = file_get_contents(codecept_data_dir('blade/qrcode-dots.png')); + $qrCodeRounded = file_get_contents(codecept_data_dir('blade/qrcode-rounded.png')); + $I->seeInSource(base64_encode($qrCodeDots)); + $I->seeInSource(base64_encode($qrCodeRounded)); + } + + public function testQrCodeComponentWithColors(FunctionalTester $I) + { + $I->wantTo('Blade Component: Assert QR Code with Colors creation'); + $I->amOnRoute('app.colors'); + $qrCodeBackground = file_get_contents(codecept_data_dir('blade/qrcode-background.png')); + $qrCodeForeground = file_get_contents(codecept_data_dir('blade/qrcode-foreground.png')); + $I->seeInSource(base64_encode($qrCodeBackground)); + $I->seeInSource(base64_encode($qrCodeForeground)); + } +} \ No newline at end of file diff --git a/tests/laravel-functional/_bootstrap.php b/tests/laravel-functional/_bootstrap.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/tests/laravel-functional/_bootstrap.php @@ -0,0 +1 @@ +setWriter(new EpsWriter()) ->writeDataUri(); - file_put_contents(codecept_data_dir('colors/uniform.eps'), $eps); - file_put_contents(codecept_data_dir('colors/uniform2.eps'), $eps2); + $this->assertEquals( $this->normalizeString(file_get_contents(codecept_data_dir('colors/uniform.eps'))), $this->normalizeString($eps) @@ -49,7 +49,7 @@ public function testGradientColors() ->setForegroundColor(0, 255, 0,25) ->setForegroundEndColor(0, 0, 255,75) ->setBackgroundColor(200, 200, 200) - ->setGradientType(ColorsInterface::GRADIENT_DIAGONAL) + ->setGradientType(Gradient::GRADIENT_DIAGONAL) ->writeString(); $svg = (new QrCode('2am Technologies')) @@ -57,7 +57,7 @@ public function testGradientColors() ->setForegroundColor(0, 255, 0,25) ->setForegroundEndColor(0, 0, 255,95) ->setBackgroundColor(200, 200, 200) - ->setGradientType(ColorsInterface::GRADIENT_RADIAL) + ->setGradientType(Gradient::GRADIENT_RADIAL) ->writeString(); $png2 = (new QrCode('2am Technologies')) @@ -65,7 +65,7 @@ public function testGradientColors() ->setForegroundColor(0, 255, 0,80) ->setForegroundEndColor(0, 0, 255,50) ->setBackgroundColor(200, 200, 200) - ->setGradientType(ColorsInterface::GRADIENT_INVERSE_DIAGONAL) + ->setGradientType(Gradient::GRADIENT_INVERSE_DIAGONAL) ->writeString(); $png3 = (new QrCode('2am Technologies')) @@ -73,7 +73,7 @@ public function testGradientColors() ->setForegroundColor(0, 255, 0,75) ->setForegroundEndColor(0, 0, 255,100) ->setBackgroundColor(200, 200, 200) - ->setGradientType(ColorsInterface::GRADIENT_HORIZONTAL) + ->setGradientType(Gradient::GRADIENT_HORIZONTAL) ->writeString(); $png4 = (new QrCode('2am Technologies')) @@ -81,7 +81,7 @@ public function testGradientColors() ->setForegroundColor(0, 255, 0,75) ->setForegroundEndColor(0, 0, 255,100) ->setBackgroundColor(200, 200, 200) - ->setGradientType(ColorsInterface::GRADIENT_VERTICAL) + ->setGradientType(Gradient::GRADIENT_VERTICAL) ->writeString(); $this->assertEquals( diff --git a/tests/unit/LaravelQrCodeFactoryTest.php b/tests/unit/LaravelQrCodeFactoryTest.php new file mode 100644 index 0000000..1a22812 --- /dev/null +++ b/tests/unit/LaravelQrCodeFactoryTest.php @@ -0,0 +1,362 @@ +expectExceptionMessage('Invalid format. The given format class , `1` does not exists'); + + LaravelQrCodeFactory::make('2am. Technologies', 1); + } + + public function testInvalidQrCodeContentInteger() + { + $this->expectExceptionMessage('Invalid content. It should be String or Array, integer given'); + + LaravelQrCodeFactory::make(100); + } + + public function testInvalidQrCodeFormatInvalidClass() + { + $this->expectException(\Exception::class); + + LaravelQrCodeFactory::make('2am. Technologies', PngWriter::class); + } + + public function testCreateGradientQrCode() + { + //@TODO investigate why tests fail on CI but works properly on local + //@TODO remove file storing once it's done + $foreground = [ + 'r' => 255, + 'g' => 0, + 'b' => 0, + ]; + $foreground2 = [ + 'r' => 0, + 'g' => 0, + 'b' => 255, + 'a' => 30, + ]; + + $qrCode = LaravelQrCodeFactory::make( + '2am. Technologies', + null, + $foreground, + null, + null, + null, + $foreground2 + ) + ->writeString(); + file_put_contents(codecept_data_dir('blade/qrcode-gradient.png'), $qrCode); + $uri = file_get_contents(codecept_data_dir('blade/qrcode-gradient.png')); + + $this->assertEquals( + $this->normalizeString($qrCode), + $this->normalizeString($uri) + ); + + $qrCodeRadial = LaravelQrCodeFactory::make( + '2am. Technologies', + null, + $foreground, + null, + null, + null, + $foreground2, + null, + null, + null, + null, + null, + Gradient::GRADIENT_RADIAL + ) + ->writeString(); + + file_put_contents(codecept_data_dir('blade/qrcode-gradient-radial.png'), $qrCodeRadial); + $uri = file_get_contents(codecept_data_dir('blade/qrcode-gradient-radial.png')); + + $this->assertEquals( + $this->normalizeString($qrCodeRadial), + $this->normalizeString($uri) + ); + } + + public function testFactoryFormatText() + { + $content = '2am. Technologies'; + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::TEXT + ); + + $this->assertEquals($qrCode->getText(), $content); + } + + public function testFactoryFormatBookMark() + { + $content = [ + 'title' => '2am. Technologies', + 'url' => 'https://2am.tech', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::BOOK_MARK + ); + + $this->assertTrue( + str_contains($qrCode->getText(), 'MEBKM:TITLE:') + && str_contains($qrCode->getText(), ';URL:') + ); + } + + public function testFactoryFormatBtc() + { + $content = [ + 'name' => '2am. Technologies', + 'amount' => 1, + 'message' => 'unt test', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::BTC + ); + + $this->assertTrue(str_contains($qrCode->getText(), 'bitcoin:')); + } + + public function testFactoryFormatGeo() + { + $content = [ + 'lat' => 100, + 'lng' => 100, + 'altitude' => 1, + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::GEO + ); + + $this->assertTrue(str_contains($qrCode->getText(), 'GEO:')); + } + + public function testFactoryFormatICal() + { + $content = [ + 'summary' => 'unit test', + 'startTimestamp' => 1702451054, + 'endTimestamp' => 1702454654, + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::I_CAL + ); + $content = $qrCode->getText(); + + $this->assertTrue( + str_contains($content, 'BEGIN:VEVENT') + && str_contains($content, 'SUMMARY:') + && str_contains($content, 'DTSTART:') + && str_contains($content, 'DTEND:') + && str_contains($content, 'END:VEVENT') + ); + } + + public function testFactoryFormatMailMessage() + { + $content = [ + 'subject' => 'unit test', + 'body' => 'unit test body', + 'email' => 'testing@2am.tech', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::MAIL_MESSAGE + ); + $content = $qrCode->getText(); + + $this->assertTrue( + str_contains($content, 'MATMSG:TO:') + && str_contains($content, 'SUB:') + && str_contains($content, 'BODY:') + ); + } + + public function testFactoryFormatMailTo() + { + $content = [ + 'email' => 'testing@2am.tech', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::MAIL_TO + ); + $content = $qrCode->getText(); + + $this->assertTrue(str_contains($content, 'MAILTO:')); + } + + public function testFactoryFormatMeCard() + { + $content = [ + 'firstName' => 'unit', + 'lastName' => 'testing', + 'nickName' => 'unit testing', + 'address' => 'saint monica st', + 'phone' => '1 1111 221', + 'videoPhone' => '1 111 121', + 'birthday' => '05/11/1990', + 'note' => '', + 'email' => 'testing@2am.tech', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::ME_CARD + ); + $content = $qrCode->getText(); + + $this->assertTrue( + str_contains($content, 'MECARD:') + && str_contains($content, 'N:') + && str_contains($content, 'SOUND:') + && str_contains($content, 'TEL:') + && str_contains($content, 'TEL-AV:') + && str_contains($content, 'EMAIL:') + && str_contains($content, 'NOTE:') + && str_contains($content, 'BDAY:') + && str_contains($content, 'ADR:') + && str_contains($content, 'URL:') + && str_contains($content, 'NICKNAME:') + ); + } + + public function testFactoryFormatMms() + { + $content = [ + 'msg' => 'unit test', + 'phone' => '1 111 122', + + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::MMS + ); + $content = $qrCode->getText(); + + $this->assertTrue(str_contains($content, 'MMSTO:')); + } + + public function testFactoryFormatPhone() + { + $content = [ + 'phone' => '1 111 122', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::PHONE_FORMAT + ); + $content = $qrCode->getText(); + + $this->assertTrue(str_contains($content, 'TEL:')); + } + + public function testFactoryFormatSms() + { + $content = [ + 'phone' => '1 111 122', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::SNS_FORMAT + ); + $content = $qrCode->getText(); + + $this->assertTrue(str_contains($content, 'SMS:')); + } + + public function testFactoryFormatVCard() + { + $content = [ + 'name' => 'testing', + 'fullName' => 'unit testing', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::V_CARD + ); + $content = $qrCode->getText(); + + $this->assertTrue( + str_contains($content, 'BEGIN:VCARD') + && str_contains($content, 'END:VCARD') + ); + } + + public function testFactoryFormatWifi() + { + $content = [ + 'authentication' => 'wpa2', + 'ssid' => 'unit-testing', + 'password' => 'xxxxxxxxxx', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::WIFI + ); + $content = $qrCode->getText(); + + $this->assertTrue( + str_contains($content, 'WIFI:') + && str_contains($content, 'S:') + && str_contains($content, 'P:') + ); + } + + public function testFactoryFormatYoutube() + { + $content = [ + 'videoId' => '123456', + ]; + + $qrCode = LaravelQrCodeFactory::make( + $content, + Format::YOUTUBE + ); + $content = $qrCode->getText(); + + $this->assertTrue( + str_contains($content, 'youtube://') + ); + } + + protected function normalizeString($string) + { + return str_replace( + "\r\n", "\n", str_replace( + " ", "", $string + ) + ); + } +} \ No newline at end of file