Skip to content

Commit cc9be58

Browse files
committed
WIP
0 parents  commit cc9be58

17 files changed

+855
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_size = 4
6+
indent_style = space
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.gitattributes

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.github export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/art export-ignore
10+
/docs export-ignore
11+
/tests export-ignore
12+
/.editorconfig export-ignore
13+
/.php_cs.dist.php export-ignore
14+
/psalm.xml export-ignore
15+
/psalm.xml.dist export-ignore
16+
/testbench.yaml export-ignore
17+
/UPGRADING.md export-ignore
18+
/phpstan.neon.dist export-ignore
19+
/phpstan-baseline.neon export-ignore

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Ask a question
4+
url: https://github.com/protonemedia/laravel-minio-testing-tools/discussions/new?category=q-a
5+
about: Ask the community for help
6+
- name: Request a feature
7+
url: https://github.com/protonemedia/laravel-minio-testing-tools/discussions/new?category=ideas
8+
about: Share ideas for new features
9+
- name: Report a security issue
10+
url: https://github.com/protonemedia/laravel-minio-testing-tools/security/policy
11+
about: Learn how to notify us for sensitive bugs
12+
- name: Report a bug
13+
url: https://github.com/protonemedia/laravel-minio-testing-tools/issues/new
14+
about: Report a reproducable bug

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Please see the documentation for all configuration options:
2+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
labels:
12+
- "dependencies"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: dependabot-auto-merge
2+
on: pull_request_target
3+
4+
permissions:
5+
pull-requests: write
6+
contents: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
14+
- name: Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v1.3.1
17+
with:
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
19+
20+
- name: Auto-merge Dependabot PRs for semver-minor updates
21+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
22+
run: gh pr merge --auto --merge "$PR_URL"
23+
env:
24+
PR_URL: ${{github.event.pull_request.html_url}}
25+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26+
27+
- name: Auto-merge Dependabot PRs for semver-patch updates
28+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
29+
run: gh pr merge --auto --merge "$PR_URL"
30+
env:
31+
PR_URL: ${{github.event.pull_request.html_url}}
32+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/run-tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: run-tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
os: [ubuntu-latest]
16+
php: [8.0, 8.1]
17+
laravel: [9.*]
18+
stability: [prefer-lowest, prefer-stable]
19+
include:
20+
- laravel: 9.*
21+
testbench: 7.*
22+
23+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v3
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php }}
33+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
34+
coverage: none
35+
36+
- name: Setup problem matchers
37+
run: |
38+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
39+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
40+
41+
- name: Install dependencies
42+
run: |
43+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
44+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
45+
46+
- name: Download MinIO S3 server and client
47+
run: |
48+
wget https://dl.minio.io/server/minio/release/linux-amd64/minio -q -P /usr/local/bin/
49+
wget https://dl.minio.io/client/mc/release/linux-amd64/mc -q -P /usr/local/bin/
50+
chmod +x /usr/local/bin/minio
51+
chmod +x /usr/local/bin/mc
52+
minio --version
53+
mc --version
54+
55+
- name: Execute tests
56+
run: vendor/bin/pest

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.idea
2+
.php_cs
3+
.php_cs.cache
4+
.phpunit.result.cache
5+
build
6+
composer.lock
7+
coverage
8+
docs
9+
phpunit.xml
10+
phpstan.neon
11+
testbench.yaml
12+
vendor
13+
node_modules
14+
.php-cs-fixer.cache

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to `laravel-minio-testing-tools` will be documented in this file.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) protonemedia <pascal@protone.media>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Laravel MinIO Testing Tools
2+
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/protonemedia/laravel-minio-testing-tools.svg?style=flat-square)](https://packagist.org/packages/protonemedia/laravel-minio-testing-tools)
4+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
5+
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/protonemedia/laravel-minio-testing-tools/run-tests?label=tests)](https://github.com/protonemedia/laravel-minio-testing-tools/actions?query=workflow%3Arun-tests+branch%3Amain)
6+
[![Total Downloads](https://img.shields.io/packagist/dt/protonemedia/laravel-minio-testing-tools.svg?style=flat-square)](https://packagist.org/packages/protonemedia/laravel-minio-testing-tools)
7+
[![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/protonemedia/laravel-minio-testing-tools)
8+
9+
This package provides a trait to run your tests against a MinIO S3 server.
10+
11+
## Support
12+
13+
We proudly support the community by developing Laravel packages and giving them away for free. Keeping track of issues and pull requests takes time, but we're happy to help! If this package saves you time or if you're relying on it professionally, please consider [supporting the maintenance and development](https://github.com/sponsors/pascalbaljet).
14+
15+
## Features
16+
* Starts and configures a MinIO server for your tests.
17+
* Updates the `filesystems` disk configuration.
18+
* Updates and restores the `.env` file.
19+
* Works with [Laravel Dusk](https://laravel.com/docs/9.x/dusk).
20+
* Works on [GitHub Actions](#github-actions)
21+
* Compatible with Laravel 9.0.
22+
* PHP 8.0 or higher is required.
23+
24+
## Installation
25+
26+
Make sure you've downloaded the [MinIO Server and Client](https://min.io/download#/linux) for your OS.
27+
28+
You can install the package via composer:
29+
30+
```bash
31+
composer require protonemedia/laravel-minio-testing-tools --dev
32+
```
33+
34+
Add the trait to your test, and add the `bootUsesMinIOServer` method:
35+
36+
```php
37+
<?php
38+
39+
namespace Tests\Browser\Backend;
40+
41+
use Illuminate\Foundation\Testing\DatabaseMigrations;
42+
use ProtoneMedia\LaravelMinioTestingTools\UsesMinioServer;
43+
use Tests\DuskTestCase;
44+
45+
class UploadVideoTest extends DuskTestCase
46+
{
47+
use DatabaseMigrations;
48+
use UsesMinioServer;
49+
50+
protected function setUp(): void
51+
{
52+
parent::setUp();
53+
54+
$this->bootUsesMinIOServer();
55+
}
56+
57+
/** @test */
58+
public function it_can_upload_a_video_using_multipart_upload()
59+
{
60+
}
61+
}
62+
```
63+
64+
That's it!
65+
66+
## GitHub Actions
67+
68+
The easiest way is to download the MinIO Server and Client before the tests are run:
69+
70+
```yaml
71+
jobs:
72+
test:
73+
steps:
74+
- uses: actions/checkout@v2
75+
76+
- name: Download MinIO S3 server and client
77+
run: |
78+
wget https://dl.minio.io/server/minio/release/linux-amd64/minio -q -P /usr/local/bin/
79+
wget https://dl.minio.io/client/mc/release/linux-amd64/mc -q -P /usr/local/bin/
80+
chmod +x /usr/local/bin/minio
81+
chmod +x /usr/local/bin/mc
82+
minio --version
83+
mc --version
84+
```
85+
86+
If you're using `php artisan serve`, make sure you don't use the `--no-reload` flag, as the `.env` file will be changed on-the-fly.
87+
88+
Optionally, if you want persistent storage across the test suite, you may start the server manually before the tests are run.
89+
90+
```yaml
91+
jobs:
92+
test:
93+
steps:
94+
- uses: actions/checkout@v2
95+
96+
- name: Download MinIO S3 server and client
97+
run: |
98+
wget https://dl.minio.io/server/minio/release/linux-amd64/minio -q -P /usr/local/bin/
99+
wget https://dl.minio.io/client/mc/release/linux-amd64/mc -q -P /usr/local/bin/
100+
chmod +x /usr/local/bin/minio
101+
chmod +x /usr/local/bin/mc
102+
minio --version
103+
mc --version
104+
105+
- name: Run MinIO S3 server
106+
run: |
107+
mkdir ~/s3
108+
sudo minio server ~/s3 --json > minio-log.json &
109+
110+
- name: Configure MinIO S3
111+
run: |
112+
mc config host add local http://127.0.0.1:9000 minioadmin minioadmin
113+
mc admin user add local user password
114+
mc admin policy set local readwrite user=user
115+
mc mb local/bucket-name --region=eu-west-1
116+
117+
- name: Upload Minio Logs (optional)
118+
if: failure()
119+
uses: actions/upload-artifact@v2
120+
with:
121+
name: minio
122+
path: minio-log.json
123+
```
124+
125+
In this case, you also need to supply an environment file with the MinIO configuration. This makes the configuration also accessible by the browser session when you're running Laravel Dusk.
126+
127+
```env
128+
AWS_ACCESS_KEY_ID=user
129+
AWS_SECRET_ACCESS_KEY=password
130+
AWS_DEFAULT_REGION=eu-west-1
131+
AWS_BUCKET=bucket-name
132+
AWS_URL=http://127.0.0.1:9000
133+
AWS_ENDPOINT=http://127.0.0.1:9000
134+
AWS_USE_PATH_STYLE_ENDPOINT=true
135+
```
136+
137+
## Testing
138+
139+
```bash
140+
composer test
141+
```
142+
143+
## Changelog
144+
145+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
146+
147+
## Contributing
148+
149+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
150+
151+
## Other Laravel packages
152+
153+
* [`Laravel Analytics Event Tracking`](https://github.com/protonemedia/laravel-analytics-event-tracking): Laravel package to easily send events to Google Analytics.
154+
* [`Laravel Blade On Demand`](https://github.com/protonemedia/laravel-blade-on-demand): Laravel package to compile Blade templates in memory.
155+
* [`Laravel Cross Eloquent Search`](https://github.com/protonemedia/laravel-cross-eloquent-search): Laravel package to search through multiple Eloquent models.
156+
* [`Laravel Eloquent Scope as Select`](https://github.com/protonemedia/laravel-eloquent-scope-as-select): Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes and constraints by adding them as a subquery.
157+
* [`Laravel Eloquent Where Not`](https://github.com/protonemedia/laravel-eloquent-where-not): This Laravel package allows you to flip/invert an Eloquent scope, or really any query constraint.
158+
* [`Laravel FFMpeg`](https://github.com/protonemedia/laravel-ffmpeg): This package provides an integration with FFmpeg for Laravel. The storage of the files is handled by Laravel's Filesystem.
159+
* [`Laravel Form Components`](https://github.com/protonemedia/laravel-form-components): Blade components to rapidly build forms with Tailwind CSS Custom Forms and Bootstrap 4. Supports validation, model binding, default values, translations, includes default vendor styling and fully customizable!
160+
* [`Laravel Mixins`](https://github.com/protonemedia/laravel-mixins): A collection of Laravel goodies.
161+
* [`Laravel Paddle`](https://github.com/protonemedia/laravel-paddle): Paddle.com API integration for Laravel with support for webhooks/events.
162+
* [`Laravel Verify New Email`](https://github.com/protonemedia/laravel-verify-new-email): This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.
163+
* [`Laravel WebDAV`](https://github.com/protonemedia/laravel-webdav): WebDAV driver for Laravel's Filesystem.
164+
165+
## Security
166+
167+
If you discover any security-related issues, please email code@protone.media instead of using the issue tracker. Please do not email any questions, open an issue if you have a question.
168+
169+
## Credits
170+
171+
- [Pascal Baljet](https://github.com/pascalbaljet)
172+
- [All Contributors](../../contributors)
173+
174+
## License
175+
176+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

0 commit comments

Comments
 (0)