diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php index ed64f08..0020e88 100644 --- a/core/modules/simpletest/src/BrowserTestBase.php +++ b/core/modules/simpletest/src/BrowserTestBase.php @@ -698,7 +698,7 @@ protected function drupalLogin(AccountInterface $account) { // @see BrowserTestBase::drupalUserIsLoggedIn() $account->sessionId = $this->getSession()->getCookie($this->getSessionName()); - $this->assertTrue($this->drupalUserIsLoggedIn($account), SafeMarkup::format('User %name successfully logged in.', array('name' => $account->getUsername()))); + $this->assertTrue($this->drupalUserIsLoggedIn($account), SafeMarkup::format('User %name successfully logged in.', array('%name' => $account->getUsername()))); $this->loggedInUser = $account; $this->container->get('current_user')->setAccount($account); diff --git a/core/modules/simpletest/src/CreateContentTypeTrait.php b/core/modules/simpletest/src/CreateContentTypeTrait.php new file mode 100644 index 0000000..c7ad41e --- /dev/null +++ b/core/modules/simpletest/src/CreateContentTypeTrait.php @@ -0,0 +1,48 @@ + 'foo'. + * + * @return \Drupal\node\Entity\NodeType + * Created content type. + */ + protected function drupalCreateContentType(array $values = array()) { + // Find a non-existent random type name. + if (!isset($values['type'])) { + do { + $id = strtolower($this->randomMachineName(8)); + } while (NodeType::load($id)); + } + else { + $id = $values['type']; + } + $values += array( + 'type' => $id, + 'name' => $id, + ); + $type = entity_create('node_type', $values); + $status = $type->save(); + node_add_body_field($type); + \Drupal::service('router.builder')->rebuild(); + +// $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created content type %type.', array('%type' => $type->id()))); + + return $type; + } + +} diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 2edfc81..28a7aeb 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -42,6 +42,7 @@ abstract class WebTestBase extends TestBase { use AssertContentTrait; + use CreateContentTypeTrait; use UserCreationTrait { createUser as drupalCreateUser; @@ -299,40 +300,6 @@ protected function drupalCreateNode(array $settings = array()) { } /** - * Creates a custom content type based on default settings. - * - * @param array $values - * An array of settings to change from the defaults. - * Example: 'type' => 'foo'. - * - * @return \Drupal\node\Entity\NodeType - * Created content type. - */ - protected function drupalCreateContentType(array $values = array()) { - // Find a non-existent random type name. - if (!isset($values['type'])) { - do { - $id = strtolower($this->randomMachineName(8)); - } while (NodeType::load($id)); - } - else { - $id = $values['type']; - } - $values += array( - 'type' => $id, - 'name' => $id, - ); - $type = entity_create('node_type', $values); - $status = $type->save(); - node_add_body_field($type); - \Drupal::service('router.builder')->rebuild(); - - $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created content type %type.', array('%type' => $type->id()))); - - return $type; - } - - /** * Builds the renderable view of an entity. * * Entities postpone the composition of their renderable arrays to #pre_render