This package provides a trait to run your tests against a MinIO S3 server.

Related tags

Laravel laravel minio
Overview

Laravel MinIO Testing Tools

Latest Version on Packagist Software License GitHub Tests Action Status Total Downloads Buy us a tree

This package provides a trait to run your tests against a MinIO S3 server.

đź“ť Blog post: https://protone.media/en/blog/how-to-use-a-local-minio-s3-server-with-laravel-and-automatically-configure-it-for-your-laravel-dusk-test-suite

Support

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.

Features

  • Starts and configures a MinIO server for your tests.
  • Updates the filesystems disk configuration.
  • Updates and restores the .env file.
  • Works with Laravel Dusk.
  • Works on GitHub Actions
  • Compatible with Laravel 9.0.
  • PHP 8.0 or higher is required.

Installation

Make sure you've downloaded the MinIO Server and Client for your OS.

You can install the package via composer:

composer require protonemedia/laravel-minio-testing-tools --dev

Add the trait to your test, and add the bootUsesMinIOServer method:

<?php

namespace Tests\Browser;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use ProtoneMedia\LaravelMinioTestingTools\UsesMinIOServer;
use Tests\DuskTestCase;

class UploadVideoTest extends DuskTestCase
{
    use DatabaseMigrations;
    use UsesMinIOServer;

    protected function setUp(): void
    {
        parent::setUp();

        $this->bootUsesMinIOServer();
    }

    /** @test */
    public function it_can_upload_a_video_using_multipart_upload()
    {
    }
}

That's it!

GitHub Actions

The easiest way is to download the MinIO Server and Client before the tests are run:

jobs:
  test:
    steps:
      - uses: actions/checkout@v2

      - name: Download MinIO S3 server and client
        run: |
          wget https://dl.minio.io/server/minio/release/linux-amd64/minio -q -P /usr/local/bin/
          wget https://dl.minio.io/client/mc/release/linux-amd64/mc -q -P /usr/local/bin/
          chmod +x /usr/local/bin/minio
          chmod +x /usr/local/bin/mc
          minio --version
          mc --version

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.

Optionally, if you want persistent storage across the test suite, you may start the server manually before the tests are run.

jobs:
  test:
    steps:
      - uses: actions/checkout@v2

      - name: Download MinIO S3 server and client
        run: |
          wget https://dl.minio.io/server/minio/release/linux-amd64/minio -q -P /usr/local/bin/
          wget https://dl.minio.io/client/mc/release/linux-amd64/mc -q -P /usr/local/bin/
          chmod +x /usr/local/bin/minio
          chmod +x /usr/local/bin/mc
          minio --version
          mc --version

      - name: Run MinIO S3 server
        run: |
          mkdir ~/s3
          sudo minio server ~/s3 --json > minio-log.json &

      - name: Configure MinIO S3
        run: |
          mc config host add local http://127.0.0.1:9000 minioadmin minioadmin
          mc admin user add local user password
          mc admin policy set local readwrite user=user
          mc mb local/bucket-name --region=eu-west-1

      - name: Upload Minio Logs (optional)
        if: failure()
        uses: actions/upload-artifact@v2
        with:
          name: minio
          path: minio-log.json

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.

AWS_ACCESS_KEY_ID=user
AWS_SECRET_ACCESS_KEY=password
AWS_DEFAULT_REGION=eu-west-1
AWS_BUCKET=bucket-name
AWS_URL=http://127.0.0.1:9000
AWS_ENDPOINT=http://127.0.0.1:9000
AWS_USE_PATH_STYLE_ENDPOINT=true

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Other Laravel packages

  • Laravel Analytics Event Tracking: Laravel package to easily send events to Google Analytics.
  • Laravel Blade On Demand: Laravel package to compile Blade templates in memory.
  • Laravel Cross Eloquent Search: Laravel package to search through multiple Eloquent models.
  • 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.
  • Laravel Eloquent Where Not: This Laravel package allows you to flip/invert an Eloquent scope, or really any query constraint.
  • Laravel FFMpeg: This package provides an integration with FFmpeg for Laravel. The storage of the files is handled by Laravel's Filesystem.
  • 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!
  • Laravel Mixins: A collection of Laravel goodies.
  • Laravel Paddle: Paddle.com API integration for Laravel with support for webhooks/events.
  • 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.
  • Laravel WebDAV: WebDAV driver for Laravel's Filesystem.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker. Please do not email any questions, open an issue if you have a question.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Chrome extension to generate Laravel integration tests while using your app.

Laravel TestTools Check out the introduction post about the chrome extension. Installation git clone [email protected]:mpociot/laravel-testtools.git # i

Laravel-veneer - A suite of mocked services to use in your Laravel tests.

Laravel Veneer A suite of fixture data and methods to help make mocking 3rd party services easier. Overview Laravel Veneer aims to solve two problems

A wrapper package to run mysqldump from laravel console commands.

A wrapper package to run mysqldump from laravel console commands.

Run patches migration style in your Laravel applications.
Run patches migration style in your Laravel applications.

This package generates patch files in the same fashion Laravel generates migrations. Each file is timestamped with an up and a down method and is asso

Fully customizable and tests supported Laravel admin dashboard for developers.

Laravel Admin dashboard Like Laravel Jetstream but built with Hotwire Turbo + additional perks. Tools used: tailwindcomponents/dashboard Hotwire Turbo

Removes whitelisted unnecessary files (like tests/docs etc.) from vendor directory

Composer vendor cleanup This is a simple script for the Composer to remove unnecessary files (documentation/examples/tests etc.) from included vendor

Generator-hedley - Scaffold a headless Drupal backend, Angular app client, and Behat tests

generator-hedley Scaffold a headless Drupal backend, Angular app client, and Behat tests Hedley is a yeoman generator that scaffolds a headless Drupal

This package provides extended support for our spatie/enum package in Laravel.
This package provides extended support for our spatie/enum package in Laravel.

Laravel support for spatie/enum This package provides extended support for our spatie/enum package in Laravel. Installation You can install the packag

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant

The unobtrusive Laravel package that makes your app multi tenant. Serving multiple websites, each with one or more hostnames from the same codebase. B

Comments
Releases(1.1.0)
Owner
Protone Media
We are a Dutch software company that develops apps, websites, and cloud platforms. As we're building projects, we gladly contribute to OSS by sharing our work.
Protone Media
This package enables you to create and run a fully functioning WebSocket server in your Laravel app.

This package enables you to create and run a fully functioning WebSocket server in your Laravel app. It can optionally receive messages broadcast over ZeroMQ.

Asked.io 181 Oct 6, 2022
Testbench Component is the de-facto package that has been designed to help you write tests for your Laravel package

Laravel Testing Helper for Packages Development Testbench Component is the de-facto package that has been designed to help you write tests for your La

Orchestra Platform 1.9k Dec 29, 2022
Generate and autoload custom Helpers, Builder Scope, Service class, Trait

laravel-make-extender Generate and autoload custom helpers, It can generate multilevel helpers in the context of the directory. Generate Service class

Limewell 30 Dec 24, 2022
Trait for multilingual resource file support

⚡ Usage This library supports MultilingualResourceTrait which can be used in PluginBase. Multilingual support of resource files is possible using this

PocketMine-MP projects of PresentKim 1 Jun 7, 2022
Tag support for Laravel Eloquent models - Taggable Trait

Laravel Taggable Trait This package is not meant to handle javascript or html in any way. This package handles database storage and read/writes only.

Rob 859 Dec 11, 2022
A Single Table Inheritance Trait for Eloquent/Laravel

Single Table Inheritance Credit This code is a fork of Nanigans/single-table-inheritance. I've only updated it to work with Laravel 5 Single Table Inh

Peter Haza 15 Feb 17, 2022
Trait for Laravel testing to count/assert about database queries

counts_database_queries Trait for Laravel testing to count/assert about database queries Installing composer require ohffs/counts-database-queries-tra

null 1 Feb 23, 2022
A Single Table Inheritance Trait for Eloquent/Laravel

Single Table Inheritance Single Table Inheritance is a trait for Laravel 5.8+ Eloquent models that allows multiple models to be stored in the same dat

Jon Palmer 240 Oct 26, 2022
Livewire trait (throttling). Limiting request processing speed

Livewire Throttling Installation You can install the package via composer: composer require f1uder/livewire-throttling Usage Livewire component <?php

Fluder 5 Dec 7, 2022
Perform Self-Diagnosis Tests On Your Laravel Application

Perform Self-Diagnosis Tests On Your Laravel Application This package allows you to run self-diagnosis tests on your Laravel application. It comes wit

Beyond Code 1.4k Dec 13, 2022