You are here

public function QuickEditImageControllerTest::testFieldInfo in Drupal 9

Tests that the field info route returns expected data.

File

core/modules/quickedit/tests/src/Functional/QuickEditImageControllerTest.php, line 100

Class

QuickEditImageControllerTest
Tests the endpoints used by the "image" in-place editor.

Namespace

Drupal\Tests\quickedit\Functional

Code

public function testFieldInfo() {

  // Create a test Node.
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'title' => t('Test Node'),
  ]);
  $json = $this
    ->drupalGet('quickedit/image/info/node/' . $node
    ->id() . '/' . $this->fieldName . '/' . $node
    ->language()
    ->getId() . '/default', [
    'query' => [
      '_format' => 'json',
    ],
  ]);
  $info = Json::decode($json);

  // Assert that the default settings for our field are respected by our JSON
  // endpoint.
  $this
    ->assertTrue($info['alt_field']);
  $this
    ->assertFalse($info['title_field']);
}