You are here

protected function AggregatorPluginSettingsBaseTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php \Drupal\Tests\aggregator\Unit\Plugin\AggregatorPluginSettingsBaseTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php, line 41

Class

AggregatorPluginSettingsBaseTest
Tests settings configuration of individual aggregator plugins.

Namespace

Drupal\Tests\aggregator\Unit\Plugin

Code

protected function setUp() : void {
  $this->configFactory = $this
    ->getConfigFactoryStub([
    'aggregator.settings' => [
      'processors' => [
        'aggregator_test',
      ],
    ],
    'aggregator_test.settings' => [],
  ]);
  foreach ([
    'fetcher',
    'parser',
    'processor',
  ] as $type) {
    $this->managers[$type] = $this
      ->getMockBuilder('Drupal\\aggregator\\Plugin\\AggregatorPluginManager')
      ->disableOriginalConstructor()
      ->getMock();
    $this->managers[$type]
      ->expects($this
      ->once())
      ->method('getDefinitions')
      ->will($this
      ->returnValue([
      'aggregator_test' => [
        'title' => '',
        'description' => '',
      ],
    ]));
  }

  /** @var \Drupal\Core\Messenger\MessengerInterface|\PHPUnit\Framework\MockObject\MockBuilder $messenger */
  $messenger = $this
    ->createMock(MessengerInterface::class);
  $messenger
    ->expects($this
    ->any())
    ->method('addMessage');
  $this->settingsForm = new SettingsForm($this->configFactory, $this->managers['fetcher'], $this->managers['parser'], $this->managers['processor'], $this
    ->getStringTranslationStub());
  $this->settingsForm
    ->setMessenger($messenger);
}