1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace Spatie\EloquentSortable\Test;
- use Illuminate\Database\Schema\Blueprint;
- use Orchestra\Testbench\TestCase as Orchestra;
- abstract class TestCase extends Orchestra
- {
- public function setUp(): void
- {
- parent::setUp();
- $this->setUpDatabase();
- }
- /**
- * @param \Illuminate\Foundation\Application $app
- *
- * @return array
- */
- protected function getPackageProviders($app)
- {
- return [
- ];
- }
- /**
- * @param \Illuminate\Foundation\Application $app
- */
- protected function getEnvironmentSetUp($app)
- {
- $app['config']->set('database.default', 'sqlite');
- $app['config']->set('database.connections.sqlite', [
- 'driver' => 'sqlite',
- 'database' => ':memory:',
- 'prefix' => '',
- ]);
- }
- protected function setUpDatabase()
- {
- $this->app['db']->connection()->getSchemaBuilder()->create('dummies', function (Blueprint $table) {
- $table->increments('id');
- $table->string('name');
- $table->string('custom_column_sort');
- $table->integer('order_column');
- });
- collect(range(1, 20))->each(function (int $i) {
- Dummy::create([
- 'name' => $i,
- 'custom_column_sort' => rand(),
- ]);
- });
- }
- protected function setUpSoftDeletes()
- {
- $this->app['db']->connection()->getSchemaBuilder()->table('dummies', function (Blueprint $table) {
- $table->softDeletes();
- });
- }
- }
|