Skip to content

Commit 7546a2d

Browse files
authored
[10.x] PHP 8.5 Compatibility (#954)
* [10.x] PHP 8.5 Compatibility 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>
1 parent e943975 commit 7546a2d

File tree

6 files changed

+35
-7
lines changed

6 files changed

+35
-7
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
laravel: 11
2424
- php: 8.4
2525
laravel: 12
26+
- php: 8.5
27+
laravel: 12
2628
- php: 8.2
2729
laravel: 9
2830
- php: 8.1

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@
2929
"typesense/typesense-php": "^4.9.3",
3030
"meilisearch/meilisearch-php": "^1.0",
3131
"mockery/mockery": "^1.0",
32-
"orchestra/testbench": "^7.31|^8.11|^9.0|^10.0",
32+
"orchestra/testbench": "^7.31|^8.36|^9.15|^10.8",
3333
"php-http/guzzle7-adapter": "^1.0",
34-
"phpstan/phpstan": "^1.10",
35-
"phpunit/phpunit": "^9.3|^10.4|^11.5"
34+
"phpstan/phpstan": "^1.10"
3635
},
3736
"conflict": {
3837
"algolia/algoliasearch-client-php": "<3.2.0|>=5.0.0"

tests/Integration/AlgoliaSearchableTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Laravel\Scout\Tests\Integration;
44

5+
use Orchestra\Sidekick\Env;
56
use Orchestra\Testbench\Attributes\RequiresEnv;
67
use Workbench\App\Models\SearchableUser;
78

@@ -215,6 +216,17 @@ public function test_it_can_use_raw_cursor_search_with_after_raw_search_callback
215216
$this->assertArrayHasKey('processingTimeMS', $rawResults);
216217
}
217218

219+
/** {@inheritdoc} */
220+
#[\Override]
221+
protected static function flushIndexesFromScout(): void
222+
{
223+
if (! Env::has('ALGOLIA_APP_ID')) {
224+
return;
225+
}
226+
227+
parent::flushIndexesFromScout();
228+
}
229+
218230
protected static function scoutDriver(): string
219231
{
220232
return 'algolia';

tests/Integration/TestCase.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,20 @@ protected function importScoutIndexFrom($model = null)
2626
* Clean up the testing environment before the next test case.
2727
*/
2828
public static function tearDownAfterClass(): void
29+
{
30+
static::flushIndexesFromScout();
31+
32+
parent::tearDownAfterClass();
33+
}
34+
35+
/**
36+
* Cleanup indexes from scout before starting new test.
37+
*/
38+
protected static function flushIndexesFromScout(): void
2939
{
3040
remote('scout:delete-all-indexes', [
3141
'SCOUT_DRIVER' => static::scoutDriver(),
3242
])->mustRun();
33-
34-
parent::tearDownAfterClass();
3543
}
3644

3745
abstract protected static function scoutDriver(): string;

tests/Unit/MeilisearchEngineTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
use Meilisearch\Client;
1313
use Meilisearch\Endpoints\Indexes;
1414
use Mockery as m;
15+
use Orchestra\Testbench\Concerns\InteractsWithMockery;
1516
use PHPUnit\Framework\TestCase;
1617
use stdClass;
1718

1819
class MeilisearchEngineTest extends TestCase
1920
{
21+
use InteractsWithMockery;
22+
2023
protected function setUp(): void
2124
{
2225
Config::shouldReceive('get')->with('scout.after_commit', m::any())->andReturn(false);
@@ -26,7 +29,8 @@ protected function setUp(): void
2629
protected function tearDown(): void
2730
{
2831
Container::getInstance()->flush();
29-
m::close();
32+
33+
$this->tearDownTheTestEnvironmentUsingMockery();
3034
}
3135

3236
public function test_map_ids_returns_empty_collection_if_no_hits()

tests/Unit/SearchableScopeTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
use Illuminate\Database\Eloquent\Builder;
66
use Laravel\Scout\SearchableScope;
77
use Mockery as m;
8+
use Orchestra\Testbench\Concerns\InteractsWithMockery;
89
use PHPUnit\Framework\TestCase;
910

1011
class SearchableScopeTest extends TestCase
1112
{
13+
use InteractsWithMockery;
14+
1215
protected function tearDown(): void
1316
{
14-
m::close();
17+
$this->tearDownTheTestEnvironmentUsingMockery();
1518
}
1619

1720
public function test_chunks_by_id()

0 commit comments

Comments
 (0)