PlainTextStyleTest.php in Recipe 8.2
File
tests/src/Functional/PlainTextStyleTest.php
View source
<?php
namespace Drupal\Tests\recipe\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\views\Views;
class PlainTextStyleTest extends RecipeTestBase {
protected static $modules = [
'block',
'locale',
'recipe',
'views',
];
public function testViewsStyle() {
$title = $this
->randomMachineName(16);
$description = $this
->randomMachineName(255);
$notes = $this
->randomMachineName(255);
$instructions = $this
->randomMachineName(255);
$ing_0_quantity = 1;
$ing_0_unit = 'tablespoon';
$ing_0_name = $this
->randomMachineName(16);
$ing_0_note = $this
->randomMachineName(16);
$edit = [
'title[0][value]' => $title,
'recipe_description[0][value]' => $description,
'recipe_notes[0][value]' => $notes,
'recipe_instructions[0][value]' => $instructions,
'recipe_ingredient[0][quantity]' => $ing_0_quantity,
'recipe_ingredient[0][unit_key]' => $ing_0_unit,
'recipe_ingredient[0][target_id]' => $ing_0_name,
'recipe_ingredient[0][note]' => $ing_0_note,
];
$this
->drupalPostForm('node/add/recipe', $edit, 'Save');
$this
->assertSession()
->pageTextContains(new FormattableMarkup('Recipe @title has been created.', [
'@title' => $title,
]));
$view = Views::getView('recipe_plain_text');
$view
->initDisplay();
$view->storage
->enable()
->save();
$this->container
->get('router.builder')
->rebuildIfNeeded();
$this
->drupalGet('node/1/plain-text');
$this
->assertSession()
->responseContains($title);
$this
->assertSession()
->responseContains($description);
$this
->assertSession()
->responseContains($notes);
$this
->assertSession()
->responseContains($instructions);
$this
->assertSession()
->responseContains(new FormattableMarkup('1 T @name (@note)', [
'@name' => $ing_0_name,
'@note' => $ing_0_note,
]));
}
}