public function IndividualUiTest::testIndividualTypeOperations in CRM Core 8.2
Same name and namespace in other branches
- 8 modules/crm_core_contact/src/Tests/IndividualUiTest.php \Drupal\crm_core_contact\Tests\IndividualUiTest::testIndividualTypeOperations()
Tests the individual type operations.
User with permissions 'administer individual types' should be able to create/edit/delete individual types.
File
- modules/
crm_core_contact/ src/ Tests/ IndividualUiTest.php, line 253
Class
- IndividualUiTest
- Tests the UI for Individual CRUD operations.
Namespace
Drupal\crm_core_contact\TestsCode
public function testIndividualTypeOperations() {
// Given I am logged in as a user with permission 'administer individual
// types'.
$user = $this
->drupalCreateUser([
'administer individual types',
]);
$this
->drupalLogin($user);
// When I visit the individual type admin page.
$this
->drupalGet('admin/structure/crm-core/individual-types');
// Then I should see edit, and delete links for existing contacts.
$this
->assertIndividualTypeLink('customer', 'Edit link for customer.');
$this
->assertIndividualTypeLink('customer/delete', 'Delete link for customer.');
// Given there is a individual of type 'customer.'.
Individual::create([
'type' => 'customer',
])
->save();
// When I visit the individual type admin page.
$this
->drupalGet('admin/structure/crm-core/individual-types');
// Then I should not see a delete link.
$this
->assertNoIndividualTypeLink('customer/delete', 'No delete link for individual.');
$this
->drupalGet('admin/structure/crm-core/individual-types/customer/delete');
$this
->assertResponse(403);
// When I edit the individual type.
$this
->drupalGet('admin/structure/crm-core/individual-types/customer');
$this
->assertResponse(200);
// Then I should see "Save customer type" button.
$this
->assertRaw(t('Save individual type'), 'Save individual type button is present.');
// Then I should not see a delete link.
$this
->assertNoIndividualTypeLink('customer/delete', 'No delete link on individual type form.');
}