You are here

public function ProfileTypeTest::testEdit in Profile 8

Tests editing a profile type.

File

tests/src/Functional/ProfileTypeTest.php, line 59

Class

ProfileTypeTest
Tests the profile type UI.

Namespace

Drupal\Tests\profile\Functional

Code

public function testEdit() {
  $profile_type = ProfileType::create([
    'id' => 'customer',
    'label' => 'Customer',
    'display_label' => 'Customer information',
    'registration' => FALSE,
    'allow_revisions' => TRUE,
    'new_revision' => TRUE,
  ]);
  $profile_type
    ->save();
  $this
    ->drupalGet($profile_type
    ->toUrl('edit-form'));
  $edit = [
    'label' => 'Customer!',
    'display_label' => 'Customer information!',
    'registration' => TRUE,
    'allow_revisions' => FALSE,
    'new_revision' => TRUE,
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Saved the Customer! profile type.');
  $profile_type = ProfileType::load('customer');
  $this
    ->assertEquals($edit['label'], $profile_type
    ->label());
  $this
    ->assertEquals($edit['display_label'], $profile_type
    ->getDisplayLabel());
  $this
    ->assertTrue($profile_type
    ->getRegistration());
  $this
    ->assertFalse($profile_type
    ->allowsRevisions());
  $this
    ->assertFalse($profile_type
    ->shouldCreateNewRevision());
}