ParagraphsCollectionOverviewTest.php in Paragraphs Collection 8
File
tests/src/Functional/ParagraphsCollectionOverviewTest.php
View source
<?php
namespace Drupal\Tests\paragraphs_collection\Functional;
use Drupal\paragraphs\Entity\ParagraphsType;
use Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsTestBase;
class ParagraphsCollectionOverviewTest extends ParagraphsTestBase {
public static $modules = [
'paragraphs_collection',
'paragraphs_collection_demo',
'paragraphs_collection_test',
];
protected function setUp() {
parent::setUp();
}
public function testOverviewPages() {
$this
->loginAsAdmin([
'administer paragraphs types',
'access site reports',
]);
$this
->drupalGet('/admin/reports');
$this
->assertText('Overviews of items discoverable by behavior plugins.');
$this
->clickLink('Paragraphs Collection');
$this
->assertUrl('/admin/reports/paragraphs_collection/layouts');
$this
->assertTitle('Available grid layouts | Drupal');
$this
->assertText('Grid layout label or ID');
$this
->assertText('Details');
$this
->assertText('Used in');
$this
->assertText('Three columns 1 - 1 - 2');
$this
->assertText('Three columns layout of 1/4, 1/4 and 1/2 width.');
$this
->assertText('paragraphs_collection_demo_1_1_2_column');
$this
->assertLink('Grid');
$this
->assertLinkByHref('/admin/structure/paragraphs_type/grid');
$this
->assertLink('Layouts');
$this
->clickLink('Styles');
$this
->assertUrl('/admin/reports/paragraphs_collection/styles');
$this
->assertTitle('Available styles | Drupal');
$this
->assertText('Group');
$this
->assertText('Style label or ID');
$this
->assertText('Details');
$this
->assertText('Used in');
$this
->assertText('Blue');
$this
->assertText('paragraphs-blue');
$this
->assertText('General Group');
$this
->assertLink('Container');
$this
->assertLinkByHref('/admin/structure/paragraphs_type/container');
$this
->assertLink('Layouts');
$this
->assertLink('Styles');
$paragraph_type_ids = \Drupal::entityQuery('paragraphs_type')
->execute();
$paragraphs_types = ParagraphsType::loadMultiple($paragraph_type_ids);
foreach ($paragraphs_types as $paragraphs_type) {
$paragraphs_type
->getBehaviorPlugin('grid_layout')
->setConfiguration([
'enabled' => FALSE,
]);
$paragraphs_type
->getBehaviorPlugin('style')
->setConfiguration([
'enabled' => FALSE,
]);
$paragraphs_type
->save();
}
$this
->drupalGet('/admin/reports/paragraphs_collection/layouts');
$this
->assertText('Three columns 1 - 1 - 2');
$this
->assertText('Three columns layout of 1/4, 1/4 and 1/2 width.');
$this
->assertText('paragraphs_collection_demo_1_1_2_column');
$this
->assertNoLink('Grid');
$this
->assertNoLinkByHref('/admin/structure/paragraphs_type/grid');
$this
->drupalGet('/admin/reports/paragraphs_collection/styles');
$this
->assertText('Blue');
$this
->assertText('paragraphs-blue');
$this
->assertText('General Group');
$this
->assertNoLink('Container');
$this
->assertNoLinkByHref('/admin/structure/paragraphs_type/container');
$this
->drupalPostForm('/admin/reports/paragraphs_collection/styles', [
'styles[underline][enabled]' => TRUE,
'styles[advanced][enabled]' => TRUE,
], 'Save configuration');
$this
->assertText('The configuration options have been saved.');
$this
->assertEquals([
'advanced',
'underline',
], \Drupal::config('paragraphs_collection.settings')
->get('enabled_styles'));
}
}