View source
<?php
namespace Drupal\Tests\forms_steps\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\forms_steps\Traits\FormsStepsTestTrait;
class FormsStepsNavigationTest extends BrowserTestBase {
use FormsStepsTestTrait;
protected $defaultTheme = 'stark';
public static $modules = [
'node',
'entity_test',
'field',
'field_ui',
'forms_steps',
];
protected function setUp() {
parent::setUp();
$this
->formsStepsSetup();
$this
->formsModesCreation();
}
public function testNavigation() {
drupal_flush_all_caches();
$this
->drupalGet($this->data['forms_steps']['steps'][1]['url']);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains($this->data['forms_steps']['steps'][1]['label']);
$value = 'This is an article Test Titre content';
$this
->drupalPostForm(NULL, [
'title[0][value]' => $value,
], t('Save'));
$this
->assertSession()
->pageTextContains($this->data['forms_steps']['steps'][2]['label']);
$this
->assertStringContainsStringIgnoringCase($this->data['forms_steps']['steps'][2]['url'], $this
->getUrl());
$this
->assertSession()
->pageTextContains($value);
$value2 = 'This is an article Test Titre content 2';
$this
->drupalPostForm(NULL, [
'title[0][value]' => $value2,
], t('Save'));
$this
->assertSession()
->pageTextContains($this->data['forms_steps']['steps'][3]['label']);
$this
->assertStringContainsStringIgnoringCase($this->data['forms_steps']['steps'][3]['url'], $this
->getUrl());
$value3 = 'This is a page Test Titre content';
$this
->drupalPostForm(NULL, [
'title[0][value]' => $value3,
], t('Save'));
$this
->assertSession()
->pageTextContains($this->data['forms_steps']['steps'][4]['label']);
$this
->assertStringContainsStringIgnoringCase($this->data['forms_steps']['steps'][4]['url'], $this
->getUrl());
$this
->assertSession()
->fieldExists('title[0][value]');
$this
->assertSession()
->buttonExists('Previous');
$this
->assertSession()
->fieldValueEquals('title[0][value]', $value2);
$this
->drupalPostForm(NULL, [], 'Previous');
$this
->assertSession()
->pageTextContains($this->data['forms_steps']['steps'][3]['label']);
$this
->assertSession()
->fieldValueEquals('title[0][value]', $value3);
$this
->drupalPostForm(NULL, [], 'Previous');
$this
->assertSession()
->pageTextContains($this->data['forms_steps']['steps'][2]['label']);
$this
->assertSession()
->fieldValueEquals('title[0][value]', $value2);
$this
->drupalPostForm(NULL, [], 'Previous');
$this
->assertSession()
->pageTextContains($this->data['forms_steps']['steps'][1]['label']);
$this
->assertSession()
->fieldValueEquals('title[0][value]', $value2);
$this
->assertSession()
->buttonNotExists('Previous');
}
}