X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsimpletest%2Fsrc%2FContentTypeCreationTrait.php;h=8184ce513ca2343307c59a8329869352c190c114;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=9ad0a21792153eec08d805811bcffe25fb58187d;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/simpletest/src/ContentTypeCreationTrait.php b/web/core/modules/simpletest/src/ContentTypeCreationTrait.php index 9ad0a2179..8184ce513 100644 --- a/web/core/modules/simpletest/src/ContentTypeCreationTrait.php +++ b/web/core/modules/simpletest/src/ContentTypeCreationTrait.php @@ -2,52 +2,20 @@ namespace Drupal\simpletest; -use Drupal\Component\Render\FormattableMarkup; -use Drupal\node\Entity\NodeType; +use Drupal\Tests\node\Traits\ContentTypeCreationTrait as BaseContentTypeCreationTrait; /** * Provides methods to create content type from given values. * * This trait is meant to be used only by test classes. + * + * @deprecated in Drupal 8.4.x. Will be removed before Drupal 9.0.0. Use + * \Drupal\Tests\node\Traits\ContentTypeCreationTrait instead. + * + * @see https://www.drupal.org/node/2884454 */ trait ContentTypeCreationTrait { - /** - * 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 createContentType(array $values = []) { - // 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 += [ - 'type' => $id, - 'name' => $id, - ]; - $type = NodeType::create($values); - $status = $type->save(); - node_add_body_field($type); - - if ($this instanceof \PHPUnit_Framework_TestCase) { - $this->assertSame($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', ['%type' => $type->id()]))->__toString()); - } - else { - $this->assertEqual($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', ['%type' => $type->id()]))->__toString()); - } - - return $type; - } + use BaseContentTypeCreationTrait; }