View source
<?php
namespace Drupal\Tests\entityform_block\Functional;
use Drupal\Tests\BrowserTestBase;
class EntityFormBlockTest extends BrowserTestBase {
protected $defaultTheme = 'classy';
public static $modules = array(
'node',
'block',
'entityform_block',
'taxonomy',
'comment',
'contact',
);
public function testEntityFormBlock() {
$this
->drupalCreateContentType(array(
'type' => 'article',
'name' => 'Article',
));
$admin_user = $this
->drupalCreateUser(array(
'administer blocks',
'administer nodes',
'administer site configuration',
'create article content',
'administer taxonomy',
'administer users',
));
$this
->drupalLogin($admin_user);
$this
->drupalGet('admin/structure/block/add/entityform_block/classy', [
'query' => [
'region' => 'content',
],
]);
$this
->assertNoOption('edit-settings-entity-type-bundle', 'comment.comment');
$this
->assertNoOption('edit-settings-entity-type-bundle', 'contact_message.personal');
$edit = array(
'settings[entity_type_bundle]' => 'node.article',
);
$this
->drupalPostForm(NULL, $edit, t('Save block'));
$this
->drupalGet('<front>');
$this
->assertSession()
->pageTextContains('Entity form');
$this
->assertSession()
->fieldExists('title[0][value]');
$this
->assertSession()
->fieldExists('body[0][value]');
$this
->assertSession()
->fieldExists('revision_log[0][value]');
$edit = array(
'name' => 'Vocabulary Tags',
'vid' => 'vocabulary_tags',
);
$this
->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'), [], 'taxonomy-vocabulary-form');
$this
->assertSession()
->pageTextContains('Created new vocabulary Vocabulary Tags.');
$this
->drupalGet('admin/structure/block/add/entityform_block/classy', [
'query' => [
'region' => 'content',
],
]);
$edit = array(
'settings[entity_type_bundle]' => 'taxonomy_term.vocabulary_tags',
);
$this
->drupalPostForm(NULL, $edit, t('Save block'));
$this
->drupalGet('<front>');
$this
->assertSession()
->fieldExists('name[0][value]');
$this
->assertSession()
->fieldExists('description[0][value]');
$this
->drupalGet('admin/structure/block/add/entityform_block/classy', [
'query' => [
'region' => 'content',
],
]);
$edit = array(
'settings[entity_type_bundle]' => 'user.user',
);
$this
->drupalPostForm(NULL, $edit, t('Save block'));
$this
->drupalGet('<front>');
$this
->assertSession()
->fieldExists('mail');
$this
->assertSession()
->fieldExists('name');
$this
->assertSession()
->fieldExists('pass[pass1]');
}
}