diff --git a/src/Illuminate/Database/Migrations/Migrator.php b/src/Illuminate/Database/Migrations/Migrator.php
index 35b4bb92e92a..c204e1764314 100755
--- a/src/Illuminate/Database/Migrations/Migrator.php
+++ b/src/Illuminate/Database/Migrations/Migrator.php
@@ -470,7 +470,7 @@ protected function resolvePath(string $path)
{
$class = $this->getMigrationClass($this->getMigrationName($path));
- if (class_exists($class)) {
+ if (class_exists($class) && realpath($path) == (new ReflectionClass($class))->getFileName()) {
return new $class;
}
diff --git a/tests/Integration/Migration/MigratorTest.php b/tests/Integration/Migration/MigratorTest.php
index 08dd9c97862f..e21a884e4152 100644
--- a/tests/Integration/Migration/MigratorTest.php
+++ b/tests/Integration/Migration/MigratorTest.php
@@ -76,7 +76,7 @@ public function testPretendMigrate()
{
$this->expectOutput('CreatePeopleTable: create table "people" ("id" integer not null primary key autoincrement, "name" varchar not null, "email" varchar not null, "password" varchar not null, "remember_token" varchar, "created_at" datetime, "updated_at" datetime)');
$this->expectOutput('CreatePeopleTable: create unique index "people_email_unique" on "people" ("email")');
- $this->expectOutput('2015_10_04_000000_modify_people_table: alter table "people" add column "first_name" varchar');
+ $this->expectOutput('ModifyPeopleTable: alter table "people" add column "first_name" varchar');
$this->expectOutput('2016_10_04_000000_modify_people_table: alter table "people" add column "last_name" varchar');
$this->subject->run([__DIR__.'/fixtures'], ['pretend' => true]);
diff --git a/tests/Integration/Migration/fixtures/2015_10_04_000000_modify_people_table.php b/tests/Integration/Migration/fixtures/2015_10_04_000000_modify_people_table.php
index 88ac706cd12a..c6a827583761 100644
--- a/tests/Integration/Migration/fixtures/2015_10_04_000000_modify_people_table.php
+++ b/tests/Integration/Migration/fixtures/2015_10_04_000000_modify_people_table.php
@@ -4,7 +4,8 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration {
+class ModifyPeopleTable extends Migration
+{
/**
* Run the migrations.
*
@@ -28,4 +29,4 @@ public function down()
$table->dropColumn('first_name');
});
}
-};
+}