Skip to content

Commit 45e38e0

Browse files
[5.x] PHP 8.5 Compatibility (#1658)
* [5.x] PHP 8.5 Compatibility Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> --------- Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: StyleCI Bot <bot@styleci.io>
1 parent 87012e7 commit 45e38e0

26 files changed

+243
-307
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: true
2525
matrix:
26-
php: [8.1, 8.2, 8.3, 8.4]
26+
php: [8.1, 8.2, 8.3, 8.4, 8.5]
2727
laravel: [10, 11, 12]
2828
include:
2929
- php: 8.2
@@ -39,6 +39,10 @@ jobs:
3939
exclude:
4040
- php: 8.4
4141
laravel: 10
42+
- php: 8.5
43+
laravel: 10
44+
- php: 8.5
45+
laravel: 11
4246
- php: 8.1
4347
laravel: 11
4448
- php: 8.1

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
"require-dev": {
2424
"ext-gd": "*",
2525
"guzzlehttp/guzzle": "^6.0|^7.0",
26-
"laravel/octane": "^1.4|^2.0|dev-develop",
27-
"orchestra/testbench": "^6.40|^7.37|^8.17|^9.0|^10.0",
28-
"phpstan/phpstan": "^1.10",
29-
"phpunit/phpunit": "^9.0|^10.5|^11.5"
26+
"laravel/octane": "^1.4|^2.0",
27+
"orchestra/testbench": "^6.47.1|^7.55|^8.36|^9.15|^10.8",
28+
"phpstan/phpstan": "^1.10"
3029
},
3130
"autoload": {
3231
"psr-4": {
@@ -49,7 +48,10 @@
4948
}
5049
},
5150
"config": {
52-
"sort-packages": true
51+
"sort-packages": true,
52+
"audit": {
53+
"block-insecure": false
54+
}
5355
},
5456
"scripts": {
5557
"post-autoload-dump": "@composer run prepare",

tests/FeatureTestCase.php

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010
use Laravel\Telescope\Storage\EntryModel;
1111
use Laravel\Telescope\Telescope;
1212
use Laravel\Telescope\TelescopeServiceProvider;
13-
use Orchestra\Testbench\Concerns\WithLaravelMigrations;
13+
use Orchestra\Testbench\Attributes\WithConfig;
14+
use Orchestra\Testbench\Attributes\WithMigration;
1415
use Orchestra\Testbench\Concerns\WithWorkbench;
1516
use Orchestra\Testbench\TestCase;
1617

18+
#[WithMigration]
19+
#[WithConfig('logging.default', 'errorlog')]
1720
class FeatureTestCase extends TestCase
1821
{
19-
use WithWorkbench, RefreshDatabase, WithLaravelMigrations;
22+
use WithWorkbench, RefreshDatabase;
2023

24+
/** {@inheritdoc} */
25+
#[\Override]
2126
protected function setUp(): void
2227
{
2328
parent::setUp();
@@ -28,6 +33,8 @@ protected function setUp(): void
2833
Telescope::$afterStoringHooks = [];
2934
}
3035

36+
/** {@inheritdoc} */
37+
#[\Override]
3138
protected function tearDown(): void
3239
{
3340
Telescope::flushEntries();
@@ -38,18 +45,24 @@ protected function tearDown(): void
3845
parent::tearDown();
3946
}
4047

48+
/** {@inheritdoc} */
49+
#[\Override]
4150
protected function getPackageProviders($app)
4251
{
4352
return [
4453
TelescopeServiceProvider::class,
4554
];
4655
}
4756

57+
/** {@inheritdoc} */
58+
#[\Override]
4859
public function ignorePackageDiscoveriesFrom()
4960
{
5061
return ['*', 'spatie/laravel-ray'];
5162
}
5263

64+
/** {@inheritdoc} */
65+
#[\Override]
5366
protected function resolveApplicationCore($app)
5467
{
5568
parent::resolveApplicationCore($app);
@@ -59,26 +72,19 @@ protected function resolveApplicationCore($app)
5972
});
6073
}
6174

62-
/**
63-
* @param \Illuminate\Foundation\Application $app
64-
* @return void
65-
*/
66-
protected function getEnvironmentSetUp($app)
75+
/** {@inheritdoc} */
76+
#[\Override]
77+
protected function defineEnvironment($app)
6778
{
68-
$config = $app->get('config');
69-
70-
$config->set('logging.default', 'errorlog');
71-
72-
$config->set('database.default', 'testbench');
73-
74-
$config->set('telescope.storage.database.connection', 'testbench');
75-
76-
$config->set('queue.batching.database', 'testbench');
77-
78-
$config->set('database.connections.testbench', [
79-
'driver' => 'sqlite',
80-
'database' => ':memory:',
81-
'prefix' => '',
79+
$app->make('config')->set([
80+
'database.default' => 'testbench',
81+
'telescope.storage.database.connection' => 'testbench',
82+
'queue.batching.database' => 'testbench',
83+
'database.connections.testbench' => [
84+
'driver' => 'sqlite',
85+
'database' => ':memory:',
86+
'prefix' => '',
87+
],
8288
]);
8389

8490
$app->when(DatabaseEntriesRepository::class)

tests/Http/AuthorizationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
class AuthorizationTest extends FeatureTestCase
1515
{
16+
/** {@inheritdoc} */
17+
#[\Override]
1618
protected function getPackageProviders($app)
1719
{
1820
return array_merge(
@@ -21,6 +23,8 @@ protected function getPackageProviders($app)
2123
);
2224
}
2325

26+
/** {@inheritdoc} */
27+
#[\Override]
2428
protected function setUp(): void
2529
{
2630
parent::setUp();
@@ -29,6 +33,8 @@ protected function setUp(): void
2933
$this->withoutMiddleware([ValidateCsrfToken::class]);
3034
}
3135

36+
/** {@inheritdoc} */
37+
#[\Override]
3238
protected function tearDown(): void
3339
{
3440
parent::tearDown();

tests/Http/AvatarTest.php

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,25 @@
99
use Laravel\Telescope\Telescope;
1010
use Laravel\Telescope\Tests\FeatureTestCase;
1111
use Laravel\Telescope\Watchers\LogWatcher;
12+
use Orchestra\Testbench\Attributes\WithConfig;
1213
use Psr\Log\LoggerInterface;
1314

15+
#[WithConfig('logging.default', 'syslog')]
16+
#[WithConfig('telescope.watchers', [
17+
LogWatcher::class => true,
18+
])]
1419
class AvatarTest extends FeatureTestCase
1520
{
21+
/** {@inheritdoc} */
22+
#[\Override]
1623
protected function setUp(): void
1724
{
1825
parent::setUp();
1926

2027
$this->withoutMiddleware(Authorize::class);
2128
}
2229

23-
protected function getEnvironmentSetUp($app)
24-
{
25-
parent::getEnvironmentSetUp($app);
26-
27-
$app->get('config')->set('logging.default', 'syslog');
28-
29-
$app->get('config')->set('telescope.watchers', [
30-
LogWatcher::class => true,
31-
]);
32-
}
33-
34-
/**
35-
* @test
36-
*/
37-
public function it_can_generate_avatar_url()
30+
public function test_it_can_generate_avatar_url()
3831
{
3932
$user = null;
4033

@@ -70,10 +63,7 @@ public function it_can_generate_avatar_url()
7063
]);
7164
}
7265

73-
/**
74-
* @test
75-
*/
76-
public function it_can_register_custom_avatar_path()
66+
public function test_it_can_register_custom_avatar_path()
7767
{
7868
$user = null;
7969

@@ -113,10 +103,7 @@ public function it_can_register_custom_avatar_path()
113103
]);
114104
}
115105

116-
/**
117-
* @test
118-
*/
119-
public function it_can_read_custom_avatar_path_on_null_email()
106+
public function test_it_can_read_custom_avatar_path_on_null_email()
120107
{
121108
$user = null;
122109

tests/Http/RouteTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
use Laravel\Telescope\Tests\FeatureTestCase;
1111
use Orchestra\Testbench\Http\Middleware\VerifyCsrfToken;
1212
use PHPUnit\Framework\Assert as PHPUnit;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314

1415
class RouteTest extends FeatureTestCase
1516
{
17+
/** {@inheritdoc} */
18+
#[\Override]
1619
protected function setUp(): void
1720
{
1821
parent::setUp();
@@ -46,7 +49,8 @@ public static function telescopeIndexRoutesProvider()
4649
/**
4750
* @dataProvider telescopeIndexRoutesProvider
4851
*/
49-
public function test_route($endpoint)
52+
#[DataProvider('telescopeIndexRoutesProvider')]
53+
public function test_route($endpoint, $entryType)
5054
{
5155
$this->post($endpoint)
5256
->assertSuccessful()
@@ -56,6 +60,7 @@ public function test_route($endpoint)
5660
/**
5761
* @dataProvider telescopeIndexRoutesProvider
5862
*/
63+
#[DataProvider('telescopeIndexRoutesProvider')]
5964
public function test_simple_list_of_entries($endpoint, $entryType)
6065
{
6166
$entry = EntryModelFactory::new()->create(['type' => $entryType]);

tests/Telescope/ExtractTagTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
class ExtractTagTest extends FeatureTestCase
1212
{
13-
/**
14-
* @test
15-
*/
1613
public function test_extract_tag_from_array_containing_flat_collection()
1714
{
1815
$flat_collection = EntryModelFactory::new()->create();
@@ -23,9 +20,6 @@ public function test_extract_tag_from_array_containing_flat_collection()
2320
$this->assertSame($tag, $extracted_tag[0]);
2421
}
2522

26-
/**
27-
* @test
28-
*/
2923
public function test_extract_tag_from_array_containing_deep_collection()
3024
{
3125
$deep_collection = EntryModelFactory::times(1)->create()->groupBy('type');
@@ -36,9 +30,6 @@ public function test_extract_tag_from_array_containing_deep_collection()
3630
$this->assertSame($tag, $extracted_tag[0]);
3731
}
3832

39-
/**
40-
* @test
41-
*/
4233
public function test_extract_tag_from_mailable()
4334
{
4435
$deep_collection = EntryModelFactory::times(1)->create()->groupBy('type');

tests/Telescope/TelescopeTest.php

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,28 @@
99
use Laravel\Telescope\Telescope;
1010
use Laravel\Telescope\Tests\FeatureTestCase;
1111
use Laravel\Telescope\Watchers\QueryWatcher;
12-
12+
use Orchestra\Testbench\Attributes\WithConfig;
13+
14+
#[WithConfig('telescope.watchers', [
15+
QueryWatcher::class => [
16+
'enabled' => true,
17+
'slow' => 0.9,
18+
],
19+
])]
1320
class TelescopeTest extends FeatureTestCase
1421
{
1522
private $count = 0;
1623

17-
protected function getEnvironmentSetUp($app)
18-
{
19-
parent::getEnvironmentSetUp($app);
20-
21-
$app->get('config')->set('telescope.watchers', [
22-
QueryWatcher::class => [
23-
'enabled' => true,
24-
'slow' => 0.9,
25-
],
26-
]);
27-
}
28-
24+
/** {@inheritdoc} */
25+
#[\Override]
2926
protected function tearDown(): void
3027
{
3128
Telescope::$afterRecordingHook = null;
3229

3330
parent::tearDown();
3431
}
3532

36-
/**
37-
* @test
38-
*/
39-
public function run_after_recording_callback()
33+
public function test_run_after_recording_callback()
4034
{
4135
Telescope::afterRecording(function (Telescope $telescope, IncomingEntry $entry) {
4236
$this->count++;
@@ -49,10 +43,7 @@ public function run_after_recording_callback()
4943
$this->assertSame(2, $this->count);
5044
}
5145

52-
/**
53-
* @test
54-
*/
55-
public function after_recording_callback_can_store_and_flush()
46+
public function test_after_recording_callback_can_store_and_flush()
5647
{
5748
Telescope::afterRecording(function (Telescope $telescope, IncomingEntry $entry) {
5849
if (count($telescope::$entriesQueue) > 1) {
@@ -74,10 +65,7 @@ public function after_recording_callback_can_store_and_flush()
7465
$this->assertCount(1, Telescope::$entriesQueue);
7566
}
7667

77-
/**
78-
* @test
79-
*/
80-
public function run_after_store_callback()
68+
public function test_run_after_store_callback()
8169
{
8270
$storedEntries = null;
8371
$storedBatchId = null;

0 commit comments

Comments
 (0)