TestCase.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace Spatie\EloquentSortable\Test;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Orchestra\Testbench\TestCase as Orchestra;
  5. abstract class TestCase extends Orchestra
  6. {
  7. public function setUp(): void
  8. {
  9. parent::setUp();
  10. $this->setUpDatabase();
  11. }
  12. /**
  13. * @param \Illuminate\Foundation\Application $app
  14. *
  15. * @return array
  16. */
  17. protected function getPackageProviders($app)
  18. {
  19. return [
  20. ];
  21. }
  22. /**
  23. * @param \Illuminate\Foundation\Application $app
  24. */
  25. protected function getEnvironmentSetUp($app)
  26. {
  27. $app['config']->set('database.default', 'sqlite');
  28. $app['config']->set('database.connections.sqlite', [
  29. 'driver' => 'sqlite',
  30. 'database' => ':memory:',
  31. 'prefix' => '',
  32. ]);
  33. }
  34. protected function setUpDatabase()
  35. {
  36. $this->app['db']->connection()->getSchemaBuilder()->create('dummies', function (Blueprint $table) {
  37. $table->increments('id');
  38. $table->string('name');
  39. $table->string('custom_column_sort');
  40. $table->integer('order_column');
  41. });
  42. collect(range(1, 20))->each(function (int $i) {
  43. Dummy::create([
  44. 'name' => $i,
  45. 'custom_column_sort' => rand(),
  46. ]);
  47. });
  48. }
  49. protected function setUpSoftDeletes()
  50. {
  51. $this->app['db']->connection()->getSchemaBuilder()->table('dummies', function (Blueprint $table) {
  52. $table->softDeletes();
  53. });
  54. }
  55. }