6d96aa1de1d9685b6c39270f75a796d327eabe88
[yaffs-website] / web / core / modules / aggregator / tests / src / Kernel / Migrate / MigrateAggregatorStubTest.php
1 <?php
2
3 namespace Drupal\Tests\aggregator\Kernel\Migrate;
4
5 use Drupal\migrate\MigrateException;
6 use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
7 use Drupal\migrate_drupal\Tests\StubTestTrait;
8
9 /**
10  * Test stub creation for aggregator feeds and items.
11  *
12  * @group aggregator
13  */
14 class MigrateAggregatorStubTest extends MigrateDrupalTestBase {
15
16   use StubTestTrait;
17
18   /**
19    * {@inheritdoc}
20    */
21   public static $modules = ['aggregator'];
22
23   /**
24    * {@inheritdoc}
25    */
26   protected function setUp() {
27     parent::setUp();
28     $this->installEntitySchema('aggregator_feed');
29     $this->installEntitySchema('aggregator_item');
30   }
31
32   /**
33    * Tests creation of aggregator feed stubs.
34    */
35   public function testFeedStub() {
36     $this->performStubTest('aggregator_feed');
37   }
38
39   /**
40    * Tests creation of aggregator feed items.
41    */
42   public function testItemStub() {
43     try {
44       // We expect an exception, because there's no feed to reference.
45       $this->performStubTest('aggregator_item');
46       $this->fail('Expected exception has not been thrown.');
47     }
48     catch (MigrateException $e) {
49       $this->assertIdentical($e->getMessage(),
50         'Stubbing failed, unable to generate value for field fid');
51     }
52
53     // The stub should pass when there's a feed to point to.
54     $this->createStub('aggregator_feed');
55     $this->performStubTest('aggregator_item');
56   }
57
58 }