b712d318b26c5d41f4da5fcb17018181b09a3a21
[yaffs-website] / web / core / modules / migrate / tests / src / Unit / Event / EventBaseTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate\Unit\Event;
4
5 use Drupal\migrate\Event\EventBase;
6 use Drupal\Tests\UnitTestCase;
7
8 /**
9  * @coversDefaultClass \Drupal\migrate\Event\EventBase
10  * @group migrate
11  */
12 class EventBaseTest extends UnitTestCase {
13
14   /**
15    * Test getMigration method.
16    *
17    * @covers ::__construct
18    * @covers ::getMigration
19    */
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());
26   }
27
28   /**
29    * Test logging a message.
30    *
31    * @covers ::__construct
32    * @covers ::logMessage
33    */
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');
43   }
44
45 }