6c212aff8de1488cc2773c55911250b6f546229e
[yaffs-website] / web / core / modules / datetime / tests / src / Unit / Plugin / migrate / field / d6 / DateFieldTest.php
1 <?php
2
3 namespace Drupal\Tests\datetime\Unit\Plugin\migrate\field\d6;
4
5 use Drupal\datetime\Plugin\migrate\field\d6\DateField;
6 use Drupal\migrate\MigrateException;
7 use Drupal\migrate\Plugin\MigrationInterface;
8 use Drupal\Tests\UnitTestCase;
9
10 /**
11  * @group migrate
12  * @group legacy
13  */
14 class DateFieldTest extends UnitTestCase {
15
16   /**
17    * @var \Drupal\migrate\Plugin\MigrationInterface
18    */
19   protected $migration;
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->migration = $this->prophesize(MigrationInterface::class)->reveal();
27   }
28
29   /**
30    * Tests an Exception is thrown when the field type is not a known date type.
31    *
32    * @runInSeparateProcess
33    * @expectedDeprecation DateField is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\datetime\Plugin\migrate\field\DateField instead.
34    */
35   public function testUnknownDateType($method = 'defineValueProcessPipeline') {
36     $plugin = new DateField([], '', []);
37
38     $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type.");
39     $plugin->$method($this->migration, 'field_date', ['type' => 'timestamp']);
40   }
41
42 }