3 namespace Drupal\Tests\migrate\Unit\Event;
5 use Drupal\migrate\Event\EventBase;
6 use Drupal\Tests\UnitTestCase;
9 * @coversDefaultClass \Drupal\migrate\Event\EventBase
12 class EventBaseTest extends UnitTestCase {
15 * Test getMigration method.
17 * @covers ::__construct
18 * @covers ::getMigration
20 public function testGetMigration() {
21 $migration = $this->prophesize('\Drupal\migrate\Plugin\MigrationInterface')->reveal();
22 $message_service = $this->prophesize('\Drupal\migrate\MigrateMessageInterface')->reveal();
23 $row = $this->prophesize('\Drupal\migrate\Row')->reveal();
24 $event = new EventBase($migration, $message_service, $row, [1, 2, 3]);
25 $this->assertSame($migration, $event->getMigration());
29 * Test logging a message.
31 * @covers ::__construct
32 * @covers ::logMessage
34 public function testLogMessage() {
35 $migration = $this->prophesize('\Drupal\migrate\Plugin\MigrationInterface')->reveal();
36 $message_service = $this->prophesize('\Drupal\migrate\MigrateMessageInterface');
37 $event = new EventBase($migration, $message_service->reveal());
38 // Assert that the intended calls to the services happen.
39 $message_service->display('status message', 'status')->shouldBeCalledTimes(1);
40 $event->logMessage('status message');
41 $message_service->display('warning message', 'warning')->shouldBeCalledTimes(1);
42 $event->logMessage('warning message', 'warning');