Skip to content

Commit

Permalink
Alternate cache driver on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 committed Apr 26, 2023
1 parent f9446b8 commit 1203ac5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/test-cache-drivers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "Run Tests - Cache Drivers"

on: [push, pull_request]

jobs:
cache:

runs-on: ubuntu-latest

services:
redis:
image: redis
ports:
- 6379/tcp
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
fail-fast: false

name: Cache Drivers

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv, memcache
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework" "predis/predis" --no-interaction --no-update
composer update --prefer-stable --prefer-dist --no-interaction
- name: Execute tests - memcached cache driver
run: |
vendor/bin/phpunit
env:
CACHE_DRIVER: memcached

- name: Execute tests - redis cache driver
run: |
CACHE_DRIVER="redis" vendor/bin/phpunit
env:
CACHE_DRIVER: redis
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

- name: Execute tests - database cache driver
run: |
vendor/bin/phpunit
env:
CACHE_DRIVER: database

- name: Execute tests - file cache driver
run: |
vendor/bin/phpunit
env:
CACHE_DRIVER: file

- name: Execute tests - array cache driver
run: |
vendor/bin/phpunit
env:
CACHE_DRIVER: array
1 change: 1 addition & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ protected function getEnvironmentSetUp($app)
$app['config']->set('auth.providers.users.model', User::class);

$app['config']->set('cache.prefix', 'spatie_tests---');
$app['config']->set('cache.default', getenv('CACHE_DRIVER') ?: 'array');

// FOR MANUAL TESTING OF ALTERNATE CACHE STORES:
// $app['config']->set('cache.default', 'array');
Expand Down

0 comments on commit 1203ac5

Please sign in to comment.