RngEventTypeMappingFormTest.php in RNG - Events and Registrations 8
File
src/Tests/RngEventTypeMappingFormTest.php
View source
<?php
namespace Drupal\rng\Tests;
use Drupal\field\Entity\FieldConfig;
use Drupal\rng\EventManagerInterface;
class RngEventTypeMappingFormTest extends RngWebTestBase {
public static $modules = [
'entity_test',
];
var $eventType;
protected function setUp() {
parent::setUp();
$user = $this
->drupalCreateUser([
'administer event types',
]);
$this
->drupalLogin($user);
$this->eventType = $this
->createEventType('entity_test', 'entity_test');
}
function testMappingForm() {
$this
->drupalGet($this->eventType
->toUrl('field-mapping'));
$this
->removeWhiteSpace();
$this
->assertRaw('<td>Registration type</td><td>Select which registration types are valid for this event.</td><td>Exists</td>');
$this
->assertRaw('<td>Registration groups</td><td>New registrations will be added to these groups.</td><td>Exists</td>');
$this
->assertRaw('<td>Accept new registrations</td><td></td><td>Exists</td><td></td>');
$this
->assertRaw('<td>Maximum registrations</td><td>Maximum amount of registrations for this event.</td><td>Exists</td><td></td>');
$this
->assertRaw('<td>Reply-to e-mail address</td><td>E-mail address that appears as reply-to when emails are sent from this event. Leave empty to use site default.</td><td>Exists</td>');
$this
->assertRaw('<td>Allow duplicate registrants</td><td>Allows a registrant to create more than one registration for this event.</td><td>Exists</td>');
$this
->assertRaw('<td>Minimum registrants</td><td>Minimum number of registrants per registration.</td><td>Exists</td>');
$this
->assertRaw('<td>Maximum registrants</td><td>Maximum number of registrants per registration.</td><td>Exists</td><td></td>');
}
function testMappingFormDeleted() {
$field = FieldConfig::loadByName('entity_test', 'entity_test', EventManagerInterface::FIELD_REGISTRATION_REGISTRANTS_MINIMUM);
$field
->delete();
$url = $this->eventType
->toUrl('field-mapping');
$this
->drupalGet($url);
$this
->removeWhiteSpace();
$this
->assertRaw('<td>Minimum registrants</td><td>Minimum number of registrants per registration.</td><td>Does not exist</td>');
$this
->assertFieldById('edit-table-rng-registrants-minimum-operations-create', 'Create', "Create button exists for 'minimum registrants' field");
$this
->drupalPostForm($url, [], t('Create'));
$this
->removeWhiteSpace();
$this
->assertRaw('<td>Minimum registrants</td><td>Minimum number of registrants per registration.</td><td>Exists</td>');
$this
->assertText('Field Minimum registrants added.');
}
}