PollFieldTest.php in Poll 8
File
tests/src/Functional/PollFieldTest.php
View source
<?php
namespace Drupal\Tests\poll\Functional;
use Drupal\Tests\field_ui\Traits\FieldUiTestTrait;
class PollFieldTest extends PollTestBase {
use FieldUiTestTrait;
public static $modules = [
'field_ui',
];
protected $adminPermissions = [
'administer poll form display',
'administer poll display',
'administer poll fields',
'administer polls',
'access polls',
'access administration pages',
];
protected function setUp() {
parent::setUp();
$this
->drupalPlaceBlock('system_breadcrumb_block');
}
public function testPollFields() {
$poll = $this->poll;
$this
->drupalLogin($this->admin_user);
$this
->fieldUIAddNewField('admin/config/content/poll', 'number', 'Number field', 'integer');
$this
->fieldUIAddNewField('admin/config/content/poll', 'text', 'Text field', 'string');
$this
->drupalGet('admin/config/content/poll/form-display');
$this
->assertText('Number field');
$this
->assertText('Text field');
$this
->drupalGet('poll/' . $poll
->id() . '/edit');
$this
->assertText('Number field');
$this
->assertText('Text field');
$edit = array(
'field_number[0][value]' => random_int(10, 1000),
'field_text[0][value]' => $this
->randomString(),
);
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->drupalGet('poll/' . $poll
->id());
$this
->assertText('Number field');
$this
->assertText('Text field');
}
}