You are here

public function RecipeImportFormsTest::testPlainTextSingleImport in Recipe 7

Same name and namespace in other branches
  1. 7.2 src/Tests/RecipeImportFormsTest.php \Drupal\recipe\Tests\RecipeImportFormsTest::testPlainTextSingleImport()

Test import a recipe in plain text format with the single import form.

File

src/Tests/RecipeImportFormsTest.php, line 24

Class

RecipeImportFormsTest
Tests the single and multiple recipe import forms.

Namespace

Drupal\recipe\Tests

Code

public function testPlainTextSingleImport() {

  // Enter a recipe into the import form and preview it.
  $edit = array(
    'recipe_format' => 'recipe_plaintext_import',
    'recipe_import_text' => 'Salt water

Ingredients:
2 c water (cold)
1 T salt

Instructions:
Combine water and salt in a glass.

Stir.

Description:
Basic salt water.

Notes:
Do not consume!
',
  );
  $this
    ->drupalPost('node/add/recipe/import', $edit, 'Preview');
  $this
    ->assertText('Salt water');
  $this
    ->assertText('2 c', 'Found ingredent 0 quantity and unit.');
  $this
    ->assertText('water (cold)', 'Found ingredient 0 name and note.');
  $this
    ->assertText('1 T', 'Found ingredient 1 quantity and unit.');
  $this
    ->assertText('salt', 'Found ingredient 1 name.');
  $this
    ->assertText('Instructions:
Combine water and salt in a glass.

Stir.

Description:
Basic salt water.

Notes:
Do not consume!', 'Found recipe instructions, description, and notes.');

  // Import the recipe into a node.
  $this
    ->drupalPost('node/add/recipe/import', $edit, 'Import');
  $this
    ->drupalGet('node/1');
  $this
    ->assertText('Salt water');
  $this
    ->assertText('2 c', 'Found ingredent 0 quantity and unit.');
  $this
    ->assertText('water (cold)', 'Found ingredient 0 name and note.');
  $this
    ->assertText('1 T', 'Found ingredient 1 quantity and unit.');
  $this
    ->assertText('salt', 'Found ingredient 1 name.');
  $this
    ->assertText('Combine water and salt in a glass.', 'Found the first instruction.');
  $this
    ->assertText('Stir.', 'Found the second instruction.');
  $this
    ->assertText('Basic salt water.', 'Found the recipe description.');
  $this
    ->assertText('Do not consume!', 'Found the recipe notes.');
}