You are here

public function DirectoryFetcherFeedFormTest::testFeedForm in Feeds 8.3

Tests the feed form.

@covers ::buildConfigurationForm @covers ::validateConfigurationForm @covers ::submitConfigurationForm

File

tests/src/Unit/Feeds/Fetcher/Form/DirectoryFetcherFeedFormTest.php, line 24

Class

DirectoryFetcherFeedFormTest
@coversDefaultClass \Drupal\feeds\Feeds\Fetcher\Form\DirectoryFetcherFeedForm @group feeds

Namespace

Drupal\Tests\feeds\Unit\Feeds\Fetcher\Form

Code

public function testFeedForm() {
  file_put_contents('vfs://feeds/test.txt', 'data');
  $plugin = $this
    ->prophesize(FetcherInterface::class);
  $plugin
    ->getConfiguration('allowed_schemes')
    ->willReturn([
    'vfs',
  ]);
  $plugin
    ->getConfiguration('allowed_extensions')
    ->willReturn('txt');
  $feed = $this
    ->prophesize(FeedInterface::class);
  $feed
    ->getSource()
    ->willReturn('vfs://feeds/test.txt');
  $feed
    ->setSource('vfs://feeds/test.txt')
    ->shouldBeCalled();
  $form_object = new DirectoryFetcherFeedForm();
  $form_object
    ->setStringTranslation($this
    ->getStringTranslationStub());
  $form_object
    ->setPlugin($plugin
    ->reveal());
  $form_state = new FormState();
  $form = $form_object
    ->buildConfigurationForm([], $form_state, $feed
    ->reveal());
  $form_state
    ->setValue('source', 'vfs://feeds/test.txt');
  $form_object
    ->validateConfigurationForm($form, $form_state, $feed
    ->reveal());
  $form_object
    ->submitConfigurationForm($form, $form_state, $feed
    ->reveal());
}