You are here

public function InsertImageWidgetTest::testDefaultWidgetElement in Insert 8

File

tests/src/FunctionalJavaScript/InsertImageWidgetTest.php, line 10

Class

InsertImageWidgetTest
@group insert

Namespace

Drupal\Tests\insert\FunctionalJavascript

Code

public function testDefaultWidgetElement() {
  $field_name = strtolower($this
    ->randomMachineName());
  $this
    ->createImageField($field_name, 'article');
  $images = $this
    ->drupalGetTestFiles('image');
  $this
    ->drupalGet('node/add/article');
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->attachFileToField('files[' . $field_name . '_0]', \Drupal::service('file_system')
    ->realpath($images[0]->uri));
  $this
    ->assertSession()
    ->waitForField($field_name . '[0][fids]');
  $this
    ->assertEquals(1, count($page
    ->findAll('css', '.insert')), 'Insert container node exists');
  $this
    ->assertEquals(1, count($page
    ->findAll('css', '.insert > .insert-templates')), 'Insert templates exist');
  $this
    ->assertEquals(1, count($page
    ->findAll('css', '[name="' . $field_name . '[0][insert_template][link]"]')), 'Insert link template exists');
  $this
    ->assertEquals(1, count($page
    ->findAll('css', '.insert > input.insert-filename')), 'Insert filename input node exists');
  $this
    ->assertEquals(1, count($page
    ->findAll('css', '.insert > input.insert-style')), 'Insert style input node exists');
  $this
    ->assertEquals('link', $page
    ->find('css', '.insert > .insert-style')
    ->getValue(), 'Insert style value is "link"');
  $this
    ->assertEquals(1, count($page
    ->findAll('css', '.insert input.insert-button')), 'Insert button exists');
}