diff -u b/core/modules/migrate/src/Event/MigrateMemoryLimitEvent.php b/core/modules/migrate/src/Event/MigrateMemoryLimitEvent.php --- b/core/modules/migrate/src/Event/MigrateMemoryLimitEvent.php +++ b/core/modules/migrate/src/Event/MigrateMemoryLimitEvent.php @@ -2,7 +2,7 @@ namespace Drupal\migrate\Event; -use Symfony\Component\EventDispatcher\Event; +use Drupal\Component\EventDispatcher\Event; /** * Wraps a memory limit event for event listeners. diff -u b/core/modules/migrate/src/MemoryManager.php b/core/modules/migrate/src/MemoryManager.php --- b/core/modules/migrate/src/MemoryManager.php +++ b/core/modules/migrate/src/MemoryManager.php @@ -94,7 +94,7 @@ */ protected function dispatchEvent($phase) { $event = new MigrateMemoryLimitEvent($this->getUsageRatio(), $this->getUsageInBytes(), $this->getLimit(), $phase); - $this->dispatcher->dispatch(MigrateEvents::MEMORY_LIMIT, $event); + $this->dispatcher->dispatch($event, MigrateEvents::MEMORY_LIMIT); } /** diff -u b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php --- b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -60,8 +60,7 @@ $this->migration = $this->getMigration(); $this->message = $this->createMock('Drupal\migrate\MigrateMessageInterface'); $event_dispatcher = $this->createMock('Symfony\Contracts\EventDispatcher\EventDispatcherInterface'); - $this->memoryManager = $this->createMock('Drupal\migrate\MemoryManagerInterface'); - $this->executable = new TestMigrateExecutable($this->migration, $this->message, $event_dispatcher, $this->memoryManager); + $this->executable = new TestMigrateExecutable($this->migration, $this->message, $event_dispatcher); $this->executable->setStringTranslation($this->getStringTranslationStub()); } @@ -78,7 +77,8 @@ $this->migration = $this->getMigration(); $this->message = $this->createMock('Drupal\migrate\MigrateMessageInterface'); $this->eventDispatcher = $this->createMock('Symfony\Contracts\EventDispatcher\EventDispatcherInterface'); - $this->executable = new TestMigrateExecutable($this->migration, $this->message, $this->eventDispatcher); + $this->memoryManager = $this->createMock('Drupal\migrate\MemoryManagerInterface'); + $this->executable = new TestMigrateExecutable($this->migration, $this->message, $this->eventDispatcher, $this->memoryManager); $this->executable->setStringTranslation($this->getStringTranslationStub()); } @@ -162,6 +162,9 @@ $this->idMap->expects($this->never()) ->method('saveIdMapping'); + $this->memoryManager->method('ensureMemory') + ->willReturn(TRUE); + $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); } @@ -179,9 +182,6 @@ $this->idMap->expects($this->never()) ->method('saveIdMapping'); - $this->memoryManager->method('ensureMemory') - ->willReturn(TRUE); - $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); } @@ -218,6 +218,9 @@ ->method('getDestinationPlugin') ->willReturn($destination); + $this->memoryManager->method('ensureMemory') + ->willReturn(TRUE); + $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); } @@ -239,9 +242,6 @@ ->method('display') ->with('New object was not saved, no error provided'); - $this->memoryManager->method('ensureMemory') - ->willReturn(TRUE); - $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); } @@ -269,6 +269,9 @@ $this->idMap->expects($this->never()) ->method('lookupDestinationIds'); + $this->memoryManager->method('ensureMemory') + ->willReturn(TRUE); + $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); } @@ -345,9 +348,6 @@ $this->idMap->expects($this->never()) ->method('lookupDestinationIds'); - $this->memoryManager->method('ensureMemory') - ->willReturn(TRUE); - $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); } @@ -402,9 +402,6 @@ ->method('display') ->with($exception_message); - $this->memoryManager->method('ensureMemory') - ->willReturn(TRUE); - $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); }