Skip to content

Commit

Permalink
Support for Laravel 11 and PHP 8.3
Browse files Browse the repository at this point in the history
Remove support for Laravel 8 and PHP 8.0
Migrate tests to Pest
  • Loading branch information
fab120 committed Mar 4, 2024
1 parent 1ba56a1 commit 0921802
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 173 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
name: Tests
name: Run Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
php: [8.2, 8.1, '8.0']
laravel: [10.*, 9.*, 8.*]
dependency-version: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
php: [8.1, 8.2, 8.3]
laravel: [9.*, 10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: ^6.23
- laravel: 9.*
testbench: ^7.40
- laravel: 10.*
testbench: ^8.21
- laravel: 11.*
testbench: ^9.0
exclude:
- laravel: 10.*
php: '8.0'
- php: 8.1
laravel: 11.*

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

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -42,8 +43,8 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:>=2.62.1" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: vendor/bin/phpunit
run: vendor/bin/pest
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/vendor
composer.lock
.phpunit.result.cache
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Webnuvola
Copyright (c) 2024 Webnuvola

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Laravel active
[![Latest Version on Packagist](https://img.shields.io/packagist/v/webnuvola/laravel-active.svg?style=flat-square)](https://packagist.org/packages/webnuvola/laravel-active)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/webnuvola/laravel-active/Tests?label=tests)](https://github.com/webnuvola/laravel-active/actions?query=workflow%3ATests+branch%3Amain)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/Webnuvola/laravel-active/run-tests.yml?branch=main)](https://github.com/Webnuvola/laravel-active/actions/workflows/run-tests.yml?query=branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/webnuvola/laravel-active.svg?style=flat-square)](https://packagist.org/packages/webnuvola/laravel-active)

Helper class for Laravel applications to get active class based on current route.
Expand Down
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
}
],
"require": {
"php": "^8.0",
"illuminate/http": "^8.0|^9.0|^10.0"
"php": "^8.1",
"illuminate/http": "^9.0||^10.0||^11.0"
},
"require-dev": {
"orchestra/testbench": "^6.23|^7.0|^8.0",
"phpunit/phpunit": "^9.5.27"
"orchestra/testbench": "^7.0||^8.0||^9.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.3"
},
"autoload": {
"files": ["src/helpers.php"]
Expand All @@ -27,12 +28,15 @@
}
},
"scripts": {
"test": "phpunit --testdox"
"test": "pest"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
Expand Down
17 changes: 9 additions & 8 deletions phpunit.xml.dist → phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Laravel Active tests">
<directory>tests</directory>
<testsuite name="Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./app</directory>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
138 changes: 0 additions & 138 deletions tests/ActiveTest.php

This file was deleted.

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

use Webnuvola\Laravel\Active\Tests\TestCase;

/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure you provide to your test functions is always bound to a specific PHPUnit test
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
| need to change it using the "uses()" function to bind a different classes or traits.
|
*/

uses(TestCase::class)->in('Unit');

/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| When you're writing tests, you often need to check that values meet certain conditions. The
| "expect()" function gives you access to a set of "expectations" methods that you can use
| to assert different things. Of course, you may extend the Expectation API at any time.
|
*/

expect()->extend('toBeOne', function () {
return $this->toBe(1);
});

/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
| project that you don't want to repeat in every file. Here you can also expose helpers as
| global functions to help you to reduce the number of lines of code in your test files.
|
*/

function something()
{
// ..
}
10 changes: 10 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Webnuvola\Laravel\Active\Tests;

use Orchestra\Testbench\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
//
}
Loading

0 comments on commit 0921802

Please sign in to comment.