EntityTypeCRUDTest.php in Entity Construction Kit (ECK) 8
File
tests/src/Functional/EntityTypeCRUDTest.php
View source
<?php
namespace Drupal\Tests\eck\Functional;
use Drupal\Core\Url;
class EntityTypeCRUDTest extends FunctionalTestBase {
public function testEntityCreationDoesNotResultInMismatchedEntityDefinitions() {
$this
->createEntityType([], 'TestType');
$this
->assertNoMismatchedFieldDefinitions();
}
public function testIfEntityUpdateDoesNotResultInMismatchedEntityDefinitions() {
$this
->createEntityType([], 'TestType');
$routeArguments = [
'eck_entity_type' => 'testtype',
];
$route = 'entity.eck_entity_type.edit_form';
$edit = [
'created' => FALSE,
];
$this
->drupalGet(Url::fromRoute($route, $routeArguments));
$this
->submitForm($edit, 'Update TestType');
$this
->assertNoMismatchedFieldDefinitions();
}
private function assertNoMismatchedFieldDefinitions() {
$this
->drupalGet(Url::fromRoute('system.status'));
$this
->assertSession()
->responseNotContains('Mismatched entity and/or field definitions');
}
public function testIfTooLongEntityTypeNamesAreCaughtInTime() {
$this
->createEntityType([], 'a27CharacterLongNameIssLong');
$label = 'a28CharacterLongNameIsLonger';
$edit = [
'label' => $label,
'id' => $id = strtolower($label),
];
$this
->drupalGet(Url::fromRoute('eck.entity_type.add'));
$this
->submitForm($edit, 'Create entity type');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains("Machine name cannot be longer than <em class=\"placeholder\">27</em> characters but is currently <em class=\"placeholder\">28</em> characters long.");
}
}