Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
laravel: 11
- php: 8.4
laravel: 12
- php: 8.5
laravel: 12
- php: 8.2
laravel: 9
- php: 8.1
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
"typesense/typesense-php": "^4.9.3",
"meilisearch/meilisearch-php": "^1.0",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^7.31|^8.11|^9.0|^10.0",
"orchestra/testbench": "^7.31|^8.36|^9.15|^10.8",
"php-http/guzzle7-adapter": "^1.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.3|^10.4|^11.5"
"phpstan/phpstan": "^1.10"
},
"conflict": {
"algolia/algoliasearch-client-php": "<3.2.0|>=5.0.0"
Expand Down
12 changes: 12 additions & 0 deletions tests/Integration/AlgoliaSearchableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Scout\Tests\Integration;

use Orchestra\Sidekick\Env;
use Orchestra\Testbench\Attributes\RequiresEnv;
use Workbench\App\Models\SearchableUser;

Expand Down Expand Up @@ -215,6 +216,17 @@ public function test_it_can_use_raw_cursor_search_with_after_raw_search_callback
$this->assertArrayHasKey('processingTimeMS', $rawResults);
}

/** {@inheritdoc} */
#[\Override]
protected static function flushIndexesFromScout(): void
{
if (! Env::has('ALGOLIA_APP_ID')) {
return;
}

parent::flushIndexesFromScout();
}

protected static function scoutDriver(): string
{
return 'algolia';
Expand Down
12 changes: 10 additions & 2 deletions tests/Integration/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ protected function importScoutIndexFrom($model = null)
* Clean up the testing environment before the next test case.
*/
public static function tearDownAfterClass(): void
{
static::flushIndexesFromScout();

parent::tearDownAfterClass();
}

/**
* Cleanup indexes from scout before starting new test.
*/
protected static function flushIndexesFromScout(): void
{
remote('scout:delete-all-indexes', [
'SCOUT_DRIVER' => static::scoutDriver(),
])->mustRun();

parent::tearDownAfterClass();
}

abstract protected static function scoutDriver(): string;
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/MeilisearchEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
use Meilisearch\Client;
use Meilisearch\Endpoints\Indexes;
use Mockery as m;
use Orchestra\Testbench\Concerns\InteractsWithMockery;
use PHPUnit\Framework\TestCase;
use stdClass;

class MeilisearchEngineTest extends TestCase
{
use InteractsWithMockery;

protected function setUp(): void
{
Config::shouldReceive('get')->with('scout.after_commit', m::any())->andReturn(false);
Expand All @@ -26,7 +29,8 @@ protected function setUp(): void
protected function tearDown(): void
{
Container::getInstance()->flush();
m::close();

$this->tearDownTheTestEnvironmentUsingMockery();
}

public function test_map_ids_returns_empty_collection_if_no_hits()
Expand Down
5 changes: 4 additions & 1 deletion tests/Unit/SearchableScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
use Illuminate\Database\Eloquent\Builder;
use Laravel\Scout\SearchableScope;
use Mockery as m;
use Orchestra\Testbench\Concerns\InteractsWithMockery;
use PHPUnit\Framework\TestCase;

class SearchableScopeTest extends TestCase
{
use InteractsWithMockery;

protected function tearDown(): void
{
m::close();
$this->tearDownTheTestEnvironmentUsingMockery();
}

public function test_chunks_by_id()
Expand Down