Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit 032dd81

Browse files
committed
WIP
1 parent 95e1510 commit 032dd81

File tree

5 files changed

+57
-79
lines changed

5 files changed

+57
-79
lines changed

composer.json

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
"license": "MIT",
1111
"authors": [
1212
{
13-
"name": "Sebastian Fix",
14-
"email": "sebastian.fix@codebar.ch",
13+
"name": "Sebastian Bürgin-Fix",
14+
"email": "sebastian.buergin@buergin.ch",
1515
"homepage": "https://www.codebar.ch",
16-
"role": "Developer"
16+
"role": "Sofware-Engineer"
17+
},
18+
{
19+
"name": "Rhys Lees",
20+
"role": "Software-Engineer"
1721
},
1822
{
1923
"name": "Casper Lai",
@@ -28,15 +32,20 @@
2832
}
2933
],
3034
"require": {
31-
"php": "^8.2|^8.3",
35+
"php": "8.2.*|8.3.*|8.4.*",
3236
"guzzlehttp/guzzle": "^7.8",
33-
"illuminate/support": "^11.0|^12.0",
37+
"illuminate/contracts": "^12.0",
3438
"symfony/psr-http-message-bridge": "^7.0"
3539
},
3640
"require-dev": {
37-
"friendsofphp/php-cs-fixer": "^3.50",
38-
"orchestra/testbench": "^9.0|^10.0",
39-
"phpunit/phpunit": "^10.5|^11.5.3"
41+
"laravel/pint": "^1.21",
42+
"larastan/larastan": "^v3.1",
43+
"orchestra/testbench": "^10.0",
44+
"pestphp/pest": "^3.7",
45+
"phpstan/extension-installer": "^1.4",
46+
"phpstan/phpstan-deprecation-rules": "^2.0",
47+
"phpstan/phpstan-phpunit": "^2.0",
48+
"spatie/laravel-ray": "^1.39"
4049
},
4150
"autoload": {
4251
"psr-4": {
@@ -56,7 +65,8 @@
5665
"config": {
5766
"sort-packages": true,
5867
"allow-plugins": {
59-
"pestphp/pest-plugin": true
68+
"pestphp/pest-plugin": true,
69+
"phpstan/extension-installer": true
6070
}
6171
},
6272
"extra": {

phpunit.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="Test Suite">
9+
<directory suffix="Test.php">./tests</directory>
10+
</testsuite>
11+
</testsuites>
12+
<source>
13+
<include>
14+
<directory suffix=".php">./app</directory>
15+
<directory suffix=".php">./src</directory>
16+
</include>
17+
</source>
18+
</phpunit>

tests/PrerenderMiddlewareTest.php renamed to tests/Feature/PrerenderMiddlewareTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

3-
namespace CodebarAg\LaravelPrerender\Tests;
3+
namespace CodebarAg\LaravelPrerender\Tests\Feature;
44

5+
use CodebarAg\LaravelPrerender\Tests\TestCase;
56
use GuzzleHttp\Client;
67

78
class PrerenderMiddlewareTest extends TestCase

tests/Pest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
use CodebarAg\LaravelPrerender\Tests\TestCase;
4+
5+
uses(TestCase::class)
6+
->in(__DIR__);

tests/TestCase.php

Lines changed: 12 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -3,91 +3,34 @@
33
namespace CodebarAg\LaravelPrerender\Tests;
44

55
use CodebarAg\LaravelPrerender\LaravelPrerenderServiceProvider;
6-
use CodebarAg\LaravelPrerender\PrerenderMiddleware;
7-
use GuzzleHttp\Client;
8-
use GuzzleHttp\Exception\ConnectException;
9-
use GuzzleHttp\Handler\MockHandler;
10-
use GuzzleHttp\HandlerStack;
11-
use GuzzleHttp\Psr7\Request;
12-
use GuzzleHttp\Psr7\Response;
13-
use Illuminate\Foundation\Application;
14-
use Illuminate\Foundation\Http\Kernel;
15-
use Illuminate\Support\Facades\Route;
16-
use Psr\Http\Message\RequestInterface;
6+
use Illuminate\Database\Eloquent\Factories\Factory;
7+
use Orchestra\Testbench\TestCase as Orchestra;
178

18-
class TestCase extends \Orchestra\Testbench\TestCase
9+
class TestCase extends Orchestra
1910
{
2011
protected function setUp(): void
2112
{
2213
parent::setUp();
2314

24-
$this->setupRoutes();
15+
Factory::guessFactoryNamesUsing(
16+
fn (string $modelName) => 'CodebarAg\\LaravelPrerender\\Database\\Factories\\'.class_basename($modelName).'Factory',
17+
);
2518
}
2619

27-
/**
28-
* @param Application $app
29-
*/
3020
protected function getPackageProviders($app): array
3121
{
3222
return [
3323
LaravelPrerenderServiceProvider::class,
3424
];
3525
}
3626

37-
/**
38-
* @param Application $app
39-
*/
40-
protected function getEnvironmentSetUp($app): void
27+
public function getEnvironmentSetUp($app): void
4128
{
42-
$app->make(Kernel::class)->prependMiddleware(PrerenderMiddleware::class);
43-
44-
// mock guzzle client
45-
$app->bind(Client::class, function () {
46-
$mock = new MockHandler([
47-
new Response(200, ['prerender.io-mock' => true]),
48-
]);
49-
$stack = HandlerStack::create($mock);
50-
51-
return new Client(['handler' => $stack]);
52-
});
53-
}
54-
55-
protected function createMockTimeoutClient(): Client
56-
{
57-
$mock = new MockHandler([
58-
new ConnectException('Could not connect', new Request('GET', 'test')),
29+
$app['config']->set('database.default', 'sqlite');
30+
$app['config']->set('database.connections.sqlite', [
31+
'driver' => 'sqlite',
32+
'database' => ':memory:',
33+
'prefix' => '',
5934
]);
60-
61-
$stack = HandlerStack::create($mock);
62-
63-
return new Client(['handler' => $stack]);
64-
}
65-
66-
protected function createMockUrlTrackingClient(): Client
67-
{
68-
$mock = new MockHandler([
69-
function (RequestInterface $request) {
70-
return new Response(
71-
200,
72-
['prerender.io-mock' => true],
73-
(string) $request->getUri()
74-
);
75-
},
76-
]);
77-
78-
$stack = HandlerStack::create($mock);
79-
80-
return new Client(['handler' => $stack]);
81-
}
82-
83-
protected function setupRoutes(): void
84-
{
85-
Route::get('test-middleware', function () {
86-
return 'GET - Success';
87-
});
88-
89-
Route::post('test-middleware', function () {
90-
return 'Success';
91-
});
9235
}
9336
}

0 commit comments

Comments
 (0)