Skip to content

Commit

Permalink
Support Laravel 9, Add github actions (#58)
Browse files Browse the repository at this point in the history
* Add basic tests

* Add gh config

* Tweak tests

* Fix symfony
  • Loading branch information
barryvdh authored Jan 30, 2022
1 parent 22a1b56 commit 3f0a750
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.github export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
phpunit.xml.dist export-ignore
59 changes: 59 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Tests

on:
push:
branches:
- master
pull_request:
branches:
- "*"
schedule:
- cron: '0 0 * * *'

jobs:
php-tests:
runs-on: ubuntu-20.04
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1

strategy:
matrix:
php: [8.0, 7.4, 7.3, 7.2]
laravel: [8.*, 7.*, 6.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 9.*
php: 8.1
dependency-version: prefer-stable
- laravel: 9.*
php: 8.0
dependency-version: prefer-lowest
exclude:
- laravel: 8.*
php: 7.2
- php: 7.4
dependency-version: prefer-lowest
- php: 8.0
dependency-version: prefer-lowest

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: mbstring

- name: Install dependencies
run: |
composer require "illuminate/support:${{ matrix.laravel }}" --no-update --no-progress
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress
- name: Execute Unit Tests
run: composer test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
composer.phar
composer.lock
.DS_Store
.DS_Store
.phpunit.result.cache
25 changes: 19 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "barryvdh/laravel-httpcache",
"description": "HttpCache for Laravel 5",
"description": "HttpCache for Laravel",
"license": "MIT",
"keywords": ["laravel", "httpcache", "cache", "esi"],
"authors": [
Expand All @@ -10,17 +10,25 @@
}
],
"require": {
"php": ">=5.5",
"illuminate/support": "^5.5|^6|^7|^8",
"symfony/console": "^3.2|^4|^5|^8",
"symfony/http-kernel": "^3.2|^4|^5|^8",
"php": ">=7.2",
"illuminate/support": "^6|^7|^8|^9",
"symfony/console": "^4|^5|^6",
"symfony/http-kernel": "^4|^5|^6",
"barryvdh/laravel-stack-middleware": "^1.0"
},
"require-dev": {
"orchestra/testbench": "^4|^5|^6|^7"
},
"autoload": {
"psr-4": {
"Barryvdh\\HttpCache\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Barryvdh\\HttpCache\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.3-dev"
Expand All @@ -30,5 +38,10 @@
"Barryvdh\\HttpCache\\ServiceProvider"
]
}
}
},
"scripts": {
"test": "phpunit"
},
"minimum-stability": "dev",
"prefer-stable": true
}
24 changes: 24 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
18 changes: 18 additions & 0 deletions tests/CacheTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Barryvdh\HttpCache\Tests;

use Barryvdh\HttpCache\Middleware\CacheRequests;
use Barryvdh\StackMiddleware\TerminableClosureMiddleware;

class CacheTest extends TestCase
{
public function testResolveMiddleware(): void
{
/** @var CacheRequests $middleware */
$middleware = app(CacheRequests::class);

$this->assertInstanceOf(TerminableClosureMiddleware::class, $middleware);
}

}
17 changes: 17 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Barryvdh\HttpCache\Tests;

use Barryvdh\HttpCache\ServiceProvider;

abstract class TestCase extends \Orchestra\Testbench\TestCase
{
/**
* @param \Illuminate\Foundation\Application $app
* @return string[]
*/
protected function getPackageProviders($app)
{
return [ServiceProvider::class];
}
}

0 comments on commit 3f0a750

Please sign in to comment.