RefreshCommandTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Illuminate\Tests\Integration\Database;
  3. use Illuminate\Support\Facades\DB;
  4. use Orchestra\Testbench\TestCase;
  5. class RefreshCommandTest extends TestCase
  6. {
  7. public function testRefreshWithoutRealpath()
  8. {
  9. $this->app->setBasePath(__DIR__);
  10. $options = [
  11. '--path' => 'stubs/',
  12. ];
  13. $this->migrateRefreshWith($options);
  14. }
  15. public function testRefreshWithRealpath()
  16. {
  17. $options = [
  18. '--path' => realpath(__DIR__.'/stubs/'),
  19. '--realpath' => true,
  20. ];
  21. $this->migrateRefreshWith($options);
  22. }
  23. private function migrateRefreshWith(array $options)
  24. {
  25. if ($this->app['config']->get('database.default') !== 'testing') {
  26. $this->artisan('db:wipe', ['--drop-views' => true]);
  27. }
  28. $this->beforeApplicationDestroyed(function () use ($options) {
  29. $this->artisan('migrate:rollback', $options);
  30. });
  31. $this->artisan('migrate:refresh', $options);
  32. DB::table('members')->insert(['name' => 'foo', 'email' => 'foo@bar', 'password' => 'secret']);
  33. $this->assertEquals(1, DB::table('members')->count());
  34. $this->artisan('migrate:refresh', $options);
  35. $this->assertEquals(0, DB::table('members')->count());
  36. }
  37. }