MigrateAggregatorStubTest.php 1.36 KB
Newer Older
1
2
<?php

3
namespace Drupal\tests\aggregator\Kernel\Migrate;
4
5

use Drupal\migrate\MigrateException;
6
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use Drupal\migrate_drupal\Tests\StubTestTrait;

/**
 * Test stub creation for aggregator feeds and items.
 *
 * @group aggregator
 */
class MigrateAggregatorStubTest extends MigrateDrupalTestBase {

  use StubTestTrait;

  /**
   * {@inheritdoc}
   */
  public static $modules = ['aggregator'];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->installEntitySchema('aggregator_feed');
    $this->installEntitySchema('aggregator_item');
  }

  /**
   * Tests creation of aggregator feed stubs.
   */
  public function testFeedStub() {
    $this->performStubTest('aggregator_feed');
  }

  /**
   * Tests creation of aggregator feed items.
   */
  public function testItemStub() {
    try {
      // We expect an exception, because there's no feed to reference.
      $this->performStubTest('aggregator_item');
      $this->fail('Expected exception has not been thrown.');
    }
    catch (MigrateException $e) {
      $this->assertIdentical($e->getMessage(),
        'Stubbing failed, unable to generate value for field fid');
    }

    // The stub should pass when there's a feed to point to.
    $this->createStub('aggregator_feed');
    $this->performStubTest('aggregator_item');
  }

}