You are here

public function ProfileTypeTest::testDuplicate in Profile 8

Tests duplicating a profile type.

File

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

Class

ProfileTypeTest
Tests the profile type UI.

Namespace

Drupal\Tests\profile\Functional

Code

public function testDuplicate() {
  $profile_type = ProfileType::create([
    'id' => 'customer',
    'label' => 'Customer',
  ]);
  $profile_type
    ->save();
  $this
    ->drupalGet($profile_type
    ->toUrl('duplicate-form'));
  $this
    ->assertSession()
    ->fieldValueEquals('label', 'Customer');
  $edit = [
    'label' => 'Customer2',
    'id' => 'customer2',
  ];
  $this
    ->submitForm($edit, t('Save'));
  $this
    ->assertSession()
    ->pageTextContains('Saved the Customer2 profile type.');

  // Confirm that the original profile type is unchanged.
  $profile_type = ProfileType::load('customer');
  $this
    ->assertNotEmpty($profile_type);
  $this
    ->assertEquals('Customer', $profile_type
    ->label());

  // Confirm that the new profile type has the expected data.
  $profile_type = ProfileType::load('customer2');
  $this
    ->assertNotEmpty($profile_type);
  $this
    ->assertEquals('Customer2', $profile_type
    ->label());
}