-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/10.x' into feature-test
- Loading branch information
Showing
19 changed files
with
194 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
providers: | ||
- Laravel\Scout\ScoutServiceProvider | ||
|
||
migrations: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,40 +2,37 @@ | |
|
||
namespace Laravel\Scout\Tests\Feature; | ||
|
||
use Illuminate\Foundation\Testing\WithFaker; | ||
use Laravel\Scout\ScoutServiceProvider; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Foundation\Testing\LazilyRefreshDatabase; | ||
use Laravel\Scout\Tests\Fixtures\SearchableModelWithUnloadedValue; | ||
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]', | ||
'created_at' => now()->addDay(), | ||
]); | ||
|
||
UserFactory::new()->create([ | ||
'name' => 'Abigail Otwell', | ||
'email' => '[email protected]', | ||
'created_at' => now()->addDays(2), | ||
]); | ||
} | ||
|
||
|
@@ -133,4 +130,24 @@ public function test_it_can_order_results() | |
$this->assertCount(1, $models); | ||
$this->assertEquals('Taylor Otwell', $models[0]->name); | ||
} | ||
|
||
public function test_it_can_order_by_latest_and_oldest() | ||
{ | ||
$models = SearchableUserModel::search('laravel')->latest()->paginate(1, 'page', 1); | ||
$this->assertCount(1, $models); | ||
$this->assertEquals('Abigail Otwell', $models[0]->name); | ||
|
||
$models = SearchableUserModel::search('laravel')->oldest()->paginate(1, 'page', 1); | ||
$this->assertCount(1, $models); | ||
$this->assertEquals('Taylor Otwell', $models[0]->name); | ||
} | ||
|
||
public function test_it_calls_make_searchable_using_before_searching() | ||
{ | ||
Model::preventAccessingMissingAttributes(true); | ||
|
||
$models = SearchableModelWithUnloadedValue::search('loaded')->get(); | ||
|
||
$this->assertCount(2, $models); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.