2018-04-21 12:59:48 +05:00
|
|
|
<?php
|
2022-12-04 20:13:24 +00:00
|
|
|
use App\Testing\Concerns\MakesHttpRequestsEx;
|
2022-12-04 19:53:27 +00:00
|
|
|
use App\Testing\ScoutFlush;
|
2022-12-04 21:43:29 +00:00
|
|
|
use App\Testing\SyntheticMongoDbTransaction;
|
2018-04-21 12:59:48 +05:00
|
|
|
|
|
|
|
abstract class TestCase extends Laravel\Lumen\Testing\TestCase
|
|
|
|
{
|
2022-12-04 11:38:11 +00:00
|
|
|
use MakesHttpRequestsEx;
|
2022-12-04 19:53:27 +00:00
|
|
|
protected Faker\Generator $faker;
|
|
|
|
|
|
|
|
protected function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->faker = Faker\Factory::create();
|
|
|
|
}
|
2022-12-04 11:38:11 +00:00
|
|
|
|
2018-04-21 12:59:48 +05:00
|
|
|
/**
|
|
|
|
* Creates the application.
|
|
|
|
*
|
|
|
|
* @return \Laravel\Lumen\Application
|
|
|
|
*/
|
|
|
|
public function createApplication()
|
|
|
|
{
|
2022-12-04 19:53:27 +00:00
|
|
|
$app = require __DIR__.'/../bootstrap/app.php';
|
|
|
|
$database = env('DB_DATABASE', 'jikan_tests');
|
|
|
|
$app['config']->set('database.connections.mongodb.database', $database === 'jikan' ? 'jikan_test' : $database);
|
|
|
|
|
|
|
|
return $app;
|
|
|
|
}
|
|
|
|
|
2022-12-04 20:11:35 +00:00
|
|
|
protected function setUpTraits()
|
2022-12-04 19:53:27 +00:00
|
|
|
{
|
2022-12-04 20:11:35 +00:00
|
|
|
parent::setUpTraits();
|
2022-12-04 19:53:27 +00:00
|
|
|
$uses = array_flip(class_uses_recursive(get_class($this)));
|
|
|
|
|
|
|
|
// we want to empty the search index
|
|
|
|
if (isset($uses[ScoutFlush::class])) {
|
|
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
|
|
$this->runScoutFlush();
|
|
|
|
}
|
2022-12-04 21:43:29 +00:00
|
|
|
|
|
|
|
if (isset($uses[SyntheticMongoDbTransaction::class])) {
|
|
|
|
/** @noinspection PhpUndefinedMethodInspection */
|
|
|
|
$this->beginDatabaseTransaction();
|
|
|
|
}
|
2018-04-21 12:59:48 +05:00
|
|
|
}
|
|
|
|
}
|