Skip to content

Commit

Permalink
Test Improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 20, 2023
1 parent a3238e8 commit 25d30db
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 38 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"algolia/algoliasearch-client-php": "^3.2",
"meilisearch/meilisearch-php": "^1.0",
"mockery/mockery": "^1.0",
"orchestra/testbench": "^7.0|^8.0",
"orchestra/testbench": "^7.31|^8.11",
"php-http/guzzle7-adapter": "^1.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.3"
Expand Down
4 changes: 4 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
providers:
- Laravel\Scout\ScoutServiceProvider

migrations: true
14 changes: 5 additions & 9 deletions tests/Feature/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,29 @@

use Illuminate\Database\Eloquent\Factories\Sequence;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Laravel\Scout\EngineManager;
use Laravel\Scout\Engines\MeilisearchEngine;
use Laravel\Scout\ScoutServiceProvider;
use Laravel\Scout\Tests\Fixtures\SearchableUserModel;
use Mockery as m;
use Orchestra\Testbench\Concerns\WithLaravelMigrations;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;

class BuilderTest extends TestCase
{
use WithFaker;

protected function getPackageProviders($app)
{
return [ScoutServiceProvider::class];
}
use LazilyRefreshDatabase, WithFaker, WithLaravelMigrations, WithWorkbench;

protected function defineEnvironment($app)
{
$app->make('config')->set('scout.driver', 'fake');
}

protected function defineDatabaseMigrations()
protected function afterRefreshingDatabase()
{
$this->setUpFaker();
$this->loadLaravelMigrations();

UserFactory::new()->count(50)->state(new Sequence(function () {
return ['name' => 'Laravel '.$this->faker()->name()];
Expand Down
17 changes: 5 additions & 12 deletions tests/Feature/CollectionEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,25 @@

namespace Laravel\Scout\Tests\Feature;

use Illuminate\Foundation\Testing\WithFaker;
use Laravel\Scout\ScoutServiceProvider;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Laravel\Scout\Tests\Fixtures\SearchableUserModel;
use Laravel\Scout\Tests\Fixtures\SearchableUserModelWithCustomSearchableData;
use Orchestra\Testbench\Concerns\WithLaravelMigrations;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;

class CollectionEngineTest extends TestCase
{
use WithFaker;

protected function getPackageProviders($app)
{
return [ScoutServiceProvider::class];
}
use LazilyRefreshDatabase, WithLaravelMigrations, WithWorkbench;

protected function defineEnvironment($app)
{
$app->make('config')->set('scout.driver', 'collection');
}

protected function defineDatabaseMigrations()
protected function afterRefreshingDatabase()
{
$this->setUpFaker();
$this->loadLaravelMigrations();

UserFactory::new()->create([
'name' => 'Taylor Otwell',
'email' => '[email protected]',
Expand Down
16 changes: 5 additions & 11 deletions tests/Feature/DatabaseEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,25 @@

namespace Laravel\Scout\Tests\Feature;

use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Laravel\Scout\ScoutServiceProvider;
use Laravel\Scout\Tests\Fixtures\SearchableUserDatabaseModel;
use Orchestra\Testbench\Concerns\WithLaravelMigrations;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;

class DatabaseEngineTest extends TestCase
{
use WithFaker;

protected function getPackageProviders($app)
{
return [ScoutServiceProvider::class];
}
use LazilyRefreshDatabase, WithFaker, WithLaravelMigrations, WithWorkbench;

protected function defineEnvironment($app)
{
$app->make('config')->set('scout.driver', 'database');
}

protected function defineDatabaseMigrations()
protected function afterRefreshingDatabase()
{
$this->setUpFaker();
$this->loadLaravelMigrations();

UserFactory::new()->create([
'name' => 'Taylor Otwell',
'email' => '[email protected]',
Expand Down
7 changes: 2 additions & 5 deletions tests/Feature/MeilisearchEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace Laravel\Scout\Tests\Feature;

use Laravel\Scout\ScoutServiceProvider;
use Meilisearch\Client;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase;

class MeilisearchEngineTest extends TestCase
{
protected function getPackageProviders($app)
{
return [ScoutServiceProvider::class];
}
use WithWorkbench;

protected function defineEnvironment($app)
{
Expand Down

0 comments on commit 25d30db

Please sign in to comment.