Skip to content

Commit

Permalink
Added Laravel 11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Radiergummi committed Jun 21, 2024
1 parent a31666f commit 2cd3145
Show file tree
Hide file tree
Showing 7 changed files with 3,257 additions and 3,955 deletions.
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
],
"require": {
"php": "^8.2",
"illuminate/support": "^8.0|^9.0|^10.0",
"symfony/stopwatch": "^5.0|^6.2"
"illuminate/support": "^9.0|^10.0|^11.0",
"symfony/stopwatch": "^5.0|^6.2|^v7.1"
},
"require-dev": {
"laravel/octane": "^1.3",
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^9.6.5",
"laravel/octane": "^2.4.0",
"orchestra/testbench": "^v9.1.2",
"phpunit/phpunit": "^11.1",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "^4.30"
"phpstan/phpstan": "^1.11.5"
},
"autoload": {
"psr-4": {
Expand All @@ -52,7 +52,7 @@
}
},
"scripts": {
"analyze": "vendor/bin/psalm",
"analyze": "vendor/bin/phpstan analyse --level=9 src tests",
"test": "vendor/bin/phpunit",
"test:ci": "vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
Expand Down
7,102 changes: 3,210 additions & 3,892 deletions composer.lock

Large diffs are not rendered by default.

44 changes: 21 additions & 23 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true">
<testsuites>
<testsuite name="Matchory Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="build/clover.xml"/>
<html outputDirectory="build/html"/>
<text outputFile="build/coverage.txt" showOnlySummary="true"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Matchory Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<clover outputFile="build/clover.xml"/>
<html outputDirectory="build/html"/>
<text outputFile="build/coverage.txt" showOnlySummary="true"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
1 change: 1 addition & 0 deletions src/ServerTiming.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use function defined;
use function microtime;

// @phpstan-ignore-next-line
use const LARAVEL_START;

class ServerTiming
Expand Down
3 changes: 3 additions & 0 deletions src/ServerTimingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
class ServerTimingServiceProvider extends EventServiceProvider
{
/**
* @var string[]
*/
protected $subscribe = [
OctaneSubscriber::class,
EloquentSubscriber::class,
Expand Down
10 changes: 5 additions & 5 deletions tests/Middleware/ServerTimingMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
namespace Matchory\ServerTiming\Tests\Middleware;

use Illuminate\Http\Request;
use InvalidArgumentException;
use Matchory\ServerTiming\Http\Middleware\ServerTimingMiddleware;
use Matchory\ServerTiming\ServerTiming;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Stopwatch\Stopwatch;

class ServerTimingMiddlewareTest extends TestCase
{
/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_adds_a_server_timing_header(): void
{
$request = new Request();
Expand All @@ -32,14 +32,14 @@ public function it_adds_a_server_timing_header(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_is_bypassed_if_configuration_false(): void
{
// @phpstan-ignore-next-line
$this->app['config']->set('timing.enabled', false);

$request = new Request();
Expand Down
38 changes: 10 additions & 28 deletions tests/ServerTimingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
namespace Matchory\ServerTiming\Tests;

use Matchory\ServerTiming\ServerTiming;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Symfony\Component\Stopwatch\Stopwatch;

class ServerTimingTest extends TestCase
{
/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_set_custom_measures(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand All @@ -31,12 +29,10 @@ public function it_can_set_custom_measures(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_set_custom_float_measures(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand All @@ -50,12 +46,10 @@ public function it_can_set_custom_float_measures(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_set_durations_with_callables(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand All @@ -71,12 +65,10 @@ public function it_can_set_durations_with_callables(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_set_events_without_duration(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand All @@ -90,12 +82,10 @@ public function it_can_set_events_without_duration(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_set_multiple_events(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand All @@ -113,12 +103,10 @@ public function it_can_set_multiple_events(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_start_and_stop_events(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand All @@ -134,12 +122,10 @@ public function it_can_start_and_stop_events(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_start_and_stop_events_using_measure(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand All @@ -155,12 +141,10 @@ public function it_can_start_and_stop_events_using_measure(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_stop_started_events(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand All @@ -175,12 +159,10 @@ public function it_can_stop_started_events(): void
}

/**
* @test
*
* @throws Exception
* @throws ExpectationFailedException
* @throws InvalidArgumentException
*/
#[Test]
public function it_can_be_reset(): void
{
$timing = new ServerTiming(new Stopwatch());
Expand Down

0 comments on commit 2cd3145

Please sign in to comment.