You are here

public function InsertFileTest::testInsertDisabledAfterEnabling in Insert 8.2

File

tests/src/FunctionalJavaScript/InsertFileTest.php, line 39

Class

InsertFileTest
Tests Insert module's generic file insert capability.

Namespace

Drupal\Tests\insert\FunctionalJavascript

Code

public function testInsertDisabledAfterEnabling() {
  $fieldName = strtolower($this
    ->randomMachineName());
  $this
    ->createFileField($fieldName);
  $this
    ->updateInsertSettings($fieldName, [
    'styles' => [
      'link' => 1,
      'icon_link' => 1,
    ],
    'default' => 'link',
  ]);
  $this
    ->updateInsertSettings($fieldName, [
    'styles' => [
      'link' => 0,
      'icon_link' => 0,
    ],
  ]);
  $page = $this
    ->getSession()
    ->getPage();
  $files = $this
    ->drupalGetTestFiles('text');
  $this
    ->drupalGet('node/add/article');
  $page
    ->attachFileToField('files[' . $fieldName . '_0]', \Drupal::service('file_system')
    ->realpath($files[0]->uri));
  $this
    ->assertSession()
    ->waitForField($fieldName . '[0][fids]');
  $this
    ->assertEquals(0, count($page
    ->findAll('css', '.insert')), 'Insert container node does not exists');
}