Pull merge.
[yaffs-website] / web / core / modules / aggregator / tests / src / Kernel / Migrate / d7 / MigrateAggregatorItemTest.php
1 <?php
2
3 namespace Drupal\Tests\aggregator\Kernel\Migrate\d7;
4
5 use Drupal\aggregator\Entity\Item;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
7
8 /**
9  * Tests migration of aggregator items.
10  *
11  * @group migrate_drupal_7
12  */
13 class MigrateAggregatorItemTest extends MigrateDrupal7TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['aggregator'];
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function setUp() {
24     parent::setUp();
25     $this->installEntitySchema('aggregator_feed');
26     $this->installEntitySchema('aggregator_item');
27     $this->executeMigration('d7_aggregator_feed');
28     $this->executeMigration('d7_aggregator_item');
29   }
30
31   /**
32    * Test Drupal 7 aggregator item migration to Drupal 8.
33    */
34   public function testAggregatorItem() {
35     // Since the feed items can change as the fixture is updated normally,
36     // assert all migrated feed items against the values in the fixture.
37     $items = $this->sourceDatabase
38       ->select('aggregator_item', 'ai')
39       ->fields('ai')
40       ->execute();
41
42     foreach ($items as $original) {
43       /** @var \Drupal\aggregator\ItemInterface $item */
44       $item = Item::load($original->iid);
45       $this->assertIdentical($original->fid, $item->getFeedId());
46       $this->assertIdentical($original->title, $item->label());
47       // If $original->author is an empty string, getAuthor() returns NULL so
48       // we need to use assertEqual() here.
49       $this->assertEqual($original->author, $item->getAuthor());
50       $this->assertIdentical($original->description, $item->getDescription());
51       $this->assertIdentical($original->link, $item->getLink());
52       $this->assertIdentical($original->timestamp, $item->getPostedTime());
53       $this->assertIdentical('en', $item->language()->getId());
54       $this->assertIdentical($original->guid, $item->getGuid());
55     }
56   }
57
58 }