View source
<?php
namespace Drupal\recipe\Tests;
class RecipeLandingPageTest extends RecipeWebTestBase {
public static function getInfo() {
return array(
'name' => 'Recipe landing page',
'description' => 'Test the content on the Recipe module landing page.',
'group' => 'Recipe',
);
}
public function testRecipeLandingPage() {
$this
->drupalGet('recipe');
$this
->assertLink('Add a new recipe', 0);
$this
->drupalLogout();
$this
->drupalGet('recipe');
$this
->assertNoLink('Add a new recipe');
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('recipe');
$this
->assertText('Latest recipes');
$node_title = $this
->randomName(16);
$edit = array(
'type' => 'recipe',
'title' => $node_title,
'recipe_source' => array(
'value' => '',
),
'recipe_yield' => 1,
'recipe_yield_unit' => '',
'recipe_description' => array(
'value' => '',
),
'recipe_instructions' => array(
'value' => '',
),
'recipe_notes' => array(
'value' => '',
),
'recipe_prep_time' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => 1,
),
),
),
'recipe_cook_time' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => 1,
),
),
),
'recipe_ingredient' => array(
LANGUAGE_NONE => array(),
),
);
$this
->drupalCreateNode($edit);
$this
->drupalGet('recipe');
$this
->assertLink($node_title, 0);
$recent_recipe_title = $this
->randomName(16);
$edit = array(
'recipe_recent_box_title' => $recent_recipe_title,
'recipe_recent_display' => 0,
);
$this
->drupalPost('admin/config/content/recipe', $edit, t('Save configuration'));
$this
->drupalGet('recipe');
$this
->assertText($recent_recipe_title);
$this
->assertNoLink($node_title);
$edit = array(
'recipe_recent_box_enable' => FALSE,
);
$this
->drupalPost('admin/config/content/recipe', $edit, t('Save configuration'));
$this
->drupalGet('recipe');
$this
->assertNoText($recent_recipe_title);
$this
->assertNoLink($node_title);
}
}