You are here

public function FileFieldPathsPathautoTest::testUi in File (Field) Paths 8

Test File (Field) Paths Pathauto UI.

File

tests/src/Functional/FileFieldPathsPathautoTest.php, line 30

Class

FileFieldPathsPathautoTest
Test pathauto integration.

Namespace

Drupal\Tests\filefield_paths\Functional

Code

public function testUi() {

  // Create a File field.
  $field_name = mb_strtolower($this
    ->randomMachineName());
  $this
    ->createFileField($field_name, 'node', $this->contentType);

  // Ensure File (Field) Paths Pathauto settings are present and available.
  $this
    ->drupalGet("admin/structure/types/manage/{$this->contentType}/fields/node.{$this->contentType}.{$field_name}");
  $session = $this
    ->assertSession();
  foreach ([
    'path',
    'name',
  ] as $field) {

    // Pathauto checkbox is present in File settings.
    $session
      ->fieldExists("third_party_settings[filefield_paths][file_{$field}][options][pathauto]");
    $element = $this
      ->xpath('//input[@name=:name]/@disabled', [
      ':name' => "third_party_settings[filefield_paths][file_{$field}][options][pathauto]",
    ]);
    $this
      ->assertEmpty($element, 'Pathauto checkbox is not disabled in File ' . Unicode::ucfirst($field) . ' settings.');
  }
}