LayoutParagraphsTest.php in Layout Paragraphs 2.0.x
File
tests/src/Functional/LayoutParagraphsTest.php
View source
<?php
namespace Drupal\Tests\layout_paragraphs\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\field\Entity\FieldConfig;
use Drupal\Core\Session\AccountInterface;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\paragraphs\Functional\Classic\ParagraphsTestBase;
use Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsTestBaseTrait;
class LayoutParagraphsTest extends BrowserTestBase {
use ParagraphsTestBaseTrait;
protected static $modules = [
'layout_paragraphs',
'paragraphs',
'node',
'field',
'field_ui',
'block',
'paragraphs_test',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$this
->addParagraphsType('section');
$this
->addParagraphsType('text');
$this
->addParagraphedContentType('page', 'field_content', 'layout_paragraphs');
$this
->loginWithPermissions([
'administer site configuration',
'administer node fields',
'administer paragraphs types',
]);
$this
->drupalGet('admin/structure/paragraphs_type/section');
$this
->submitForm([
'behavior_plugins[layout_paragraphs][enabled]' => TRUE,
'behavior_plugins[layout_paragraphs][settings][available_layouts][]' => [
'layout_onecol',
'layout_twocol',
'layout_threecol_25_50_25',
'layout_threecol_33_34_33',
],
], 'Save');
$this
->assertSession()
->pageTextContains('Saved the section Paragraphs type.');
$this
->drupalGet('admin/structure/types/manage/page/fields/node.page.field_content');
$this
->assertSession()
->statusCodeEquals(200);
$this
->submitForm([
'settings[handler_settings][target_bundles_drag_drop][section][enabled]' => TRUE,
'settings[handler_settings][target_bundles_drag_drop][text][enabled]' => TRUE,
], 'Save settings', 'field-config-edit-form');
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalLogout();
}
public function testLayoutParagraphsConfiguration() {
$this
->loginWithPermissions([
'create page content',
'edit own page content',
]);
$this
->drupalGet('node/add/page');
$this
->assertSession()
->pageTextContains('field_content');
}
protected function loginWithPermissions(array $permissions) {
$user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($user);
return $user;
}
}