Skip to content

Commit

Permalink
add laravel 11 compatibility and tests support
Browse files Browse the repository at this point in the history
  • Loading branch information
salehhashemi1992 committed May 18, 2024
1 parent 3ccfdf1 commit cb6db1e
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 66 deletions.
45 changes: 23 additions & 22 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
name: Run Tests
name: "Run Tests"

on:
push:
branches:
- "**"
pull_request:
types: [ready_for_review, synchronize, opened]
on: [push, pull_request]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.2, 8.1]
laravel: [10.*, 9.*]
stability: [prefer-stable]
php: [8.1, 8.2, 8.3]
laravel: [9.*, 10.*, 11.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
phpunit: 11.*

- laravel: 10.*
testbench: 8.*
phpunit: 11.*

- laravel: 9.*
testbench: 7.*
phpunit: 10.*

exclude:
- laravel: 11.*
php: 8.1

- laravel: 9.*
php: 8.3

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

steps:
- name: Checkout code
Expand All @@ -33,21 +42,13 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
coverage: xdebug

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: List Installed Dependencies
run: composer show -D
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
- name: Execute tests with Coverage
run: vendor/bin/phpunit --coverage-clover=coverage.xml
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"type": "library",
"require": {
"php": "^8.1",
"illuminate/support": "^9.0|^10.0"
"laravel/framework": "^9.0|^10.0|^11.0"
},
"require-dev": {
"laravel/pint": "^1.8",
"orchestra/testbench": "^8.0",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^9.0|^10.0|^11.0"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 0 additions & 18 deletions phpunit.xml

This file was deleted.

18 changes: 14 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
colors="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
>
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>

<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
9 changes: 0 additions & 9 deletions tests/BaseTest.php

This file was deleted.

11 changes: 1 addition & 10 deletions tests/ConfigurableCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
namespace Salehhashemi\ConfigurableCache\Tests;

use Salehhashemi\ConfigurableCache\ConfigurableCache;
use Salehhashemi\ConfigurableCache\ConfigurableCacheServiceProvider;

class ConfigurableCacheTest extends BaseTest
class ConfigurableCacheTest extends TestCase
{
/**
* {@inheritdoc}
*/
protected function getPackageProviders($app): array
{
return [ConfigurableCacheServiceProvider::class];
}

public function test_get_function_retrieves_correct_value_from_cache()
{
ConfigurableCache::put('testKey', 'testValue', 'default');
Expand Down
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 Salehhashemi\ConfigurableCache\Tests;

use Orchestra\Testbench\TestCase as BaseTestCase;
use Salehhashemi\ConfigurableCache\ConfigurableCacheServiceProvider;

class TestCase extends BaseTestCase
{
/**
* {@inheritdoc}
*/
protected function getPackageProviders($app): array
{
return [ConfigurableCacheServiceProvider::class];
}
}

0 comments on commit cb6db1e

Please sign in to comment.