ItemWithoutFeedTest.php 926 Bytes
Newer Older
1
2
3
4
5
6
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
<?php

/**
 * @file
 * Contains \Drupal\aggregator\Tests\ItemWithoutFeedTest.
 */

namespace Drupal\aggregator\Tests;

use Drupal\aggregator\Entity\Item;
use Drupal\KernelTests\KernelTestBase;

/**
 * Tests clean handling of an item with a missing feed ID.
 *
 * @group aggregator
 */
class ItemWithoutFeedTest extends KernelTestBase {

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

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

  /**
   * Tests attempting to create a feed item without a feed.
   */
  public function testEntityCreation() {
    $entity = Item::create([
      'title' => t('Llama 2'),
      'path' => 'https://groups.drupal.org/',
    ]);
    $violations = $entity->validate();
    $this->assertCount(1, $violations);
  }

}