'administer entity_test display', 'administer entity_test form display', 'view the administration theme', ])); }
/**
* Tests that layouts are unique per view mode.
*/ publicfunctiontestEntityViewModes(){ // By default, the field is not visible.
$this->drupalGet('entity_test/1/test'); $this->assertSession()->elementNotExists('css', '.layout__region--content '); $this->drupalGet('entity_test/1'); $this->assertSession()->elementNotExists('css', '.layout__region--content');
// Change the layout for the "test" view mode. See
// core.entity_view_mode.entity_test.test.yml.
$this->drupalGet('entity_test/structure/entity_test/display'); $this->click('#edit-modes'); $this->getSession()->getPage()->checkField('display_modes_custom[test]'); $this->submitForm([], 'Save'); $this->clickLink('configure them');
'administer entity_test fields', 'administer entity_test display', 'administer entity_test form display', 'view the administration theme', ])); }
/**
* Tests the use of regions for entity form displays.
*/ publicfunctiontestEntityForm(){ $this->drupalGet('entity_test/manage/1/edit'); $this->assertSession()->fieldExists('field_test_text[0][value]');
// Log in as an administrator who can see the administrative theme.
$admin_user = $this->drupalCreateUser(['view the administration theme']); $this->drupalLogin($admin_user); // Visit an administrative page that runs a test batch, and check that the
// theme that was used during batch execution (which the batch callback
// function saved as a variable) matches the theme used on the
// administrative page.
$this->drupalGet('admin/batch-test/test-theme'); // The stack should contain the name of the theme used on the progress
// page.
$this->assertEquals(['claro'], batch_test_stack(), 'A progressive batch correctly uses the theme of the page that started the batch.'); }
/**
* Tests that the batch API progress page shows the title correctly.
*/ publicfunctiontestBatchProgressPageTitle(){ // Visit an administrative page that runs a test batch, and check that the
// title shown during batch execution (which the batch callback function
// Check that at least one module implements hook_node_grants() as this test
// only tests this case.
// @see \node_test_node_grants()
$this->assertTrue(\Drupal::moduleHandler()->hasImplementations('node_grants'));
// Check that the referenced entity link doesn't show on the host entity.
$this->drupalGet($node->toUrl()); $this->assertSession()->linkNotExists($referenced->label());
// Publish the referenced node.
$referenced->setPublished()->save();
// Set page revision setting 'create new revision'. This will mean new
// revisions are created by default when the node is edited.
$type = NodeType::load('page'); $type->setNewRevision(TRUE); $type->save();
// Verify the checkbox is checked on the node edit form.
$this->drupalGet('node/' . $node->id() . '/edit'); $this->assertSession()->checkboxChecked('edit-revision');
// Uncheck the create new revision checkbox and save the node.
$edit = ['revision' => FALSE]; $this->drupalGet('node/' . $node->id() . '/edit'); $this->submitForm($edit, 'Save');
// Load the node again and check the revision is the same as before.
$node_storage->resetCache([$node->id()]); $node_revision = $node_storage->load($node->id(), TRUE); $this->assertEquals($node->getRevisionId(), $node_revision->getRevisionId(), "After an existing node is saved with 'Create new revision' unchecked, a new revision is not created.");
// @todo Remove this line once https://www.drupal.org/node/2945928 is fixed.
$this->config('node.settings')->set('use_admin_theme', '1')->save(); }
/**
* Enables content moderation for the test entity type and bundle.
*/ protectedfunctionenableContentModeration(){ $this->drupalLogin($this->rootUser); $workflow_id = 'editorial'; $this->drupalGet('/admin/config/workflow/workflows'); $edit['bundles[' . $this->bundle . ']'] = TRUE; $this->drupalGet('admin/config/workflow/workflows/manage/' . $workflow_id . '/type/' . $this->entityTypeId); $this->submitForm($edit, 'Save'); // Ensure the parent environment is up-to-date.
// @see content_moderation_workflow_insert()
\Drupal::service('entity_type.bundle.info')->clearCachedBundles(); \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */ $router_builder = $this->container->get('router.builder'); $router_builder->rebuildIfNeeded(); }
/**
* Gets counter of views by path.
*
* @param string $path
* A path to node.
*
* @return int|null
* A counter of views. Returns NULL if the page does not contain statistics.
*/ protectedfunctiongetStatisticsCounter($path){ $this->drupalGet($path); // Wait while statistics module send ajax request.
$this->assertSession()->assertWaitOnAjaxRequest(); // Resaving the node to call the hook_node_links_alter(), which is used to
// update information on the page. See statistics_node_links_alter().
$this->node->save();
// We expect all 5 forum topics to appear in the "New forum topics" block.
foreach($topicsas$topic){ $this->assertSession()->linkExists($topic, 0, newFormattableMarkup('Forum topic @topic found in the "New forum topics" block.', ['@topic' => $topic])); }
'settings' => [ 'match_operator' => 'CONTAINS', ], ]); // To satisfy config schema, the size setting must be an integer, not just
// a numeric value. See https://www.drupal.org/node/2885441.
$this->assertIsInt($form_display->getComponent($field_name)['settings']['size']); $form_display->save(); $this->assertIsInt($form_display->getComponent($field_name)['settings']['size']);
/**
* Asserts whether the saved maximum dimensions equal the ones provided.
*
* @param int|null $width
* The expected width of the uploaded image.
* @param int|null $height
* The expected height of the uploaded image.
*
* @internal
*/
// Create custom fields for the media type to store metadata attributes.
$fields = [ 'field_string_file_size' => 'string', 'field_string_mime_type' => 'string', ]; $this->createMediaTypeFields($fields, $media_type_id);
// Hide the name field widget to test default name generation.
$this->hideMediaTypeFieldWidget('name', $media_type_id);
// Create a media item.
$this->drupalGet("media/add/{$media_type_id}");
$body_text = 'The Enricþment Center is cómmīŦŧęđ to the well BɆĬŇĜ of æll påŔťıçȉpǎǹţș. '; $body_text .= 'Also meklēt (see #731298)'; $this->drupalCreateNode(['body' => [['value' => $body_text]]]);
// Update the search index.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
// Refresh variables after the treatment.
$this->refreshVariables();