예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function create(array $values = array())
 {
     // @todo Handle values
     $user = new User();
     $user->setIsNew(true);
     // Sad but true story, this'll work
     foreach ($values as $key => $value) {
         $user->{$key} = $value;
     }
     return $user;
 }
 protected function setUp()
 {
     parent::setUp();
     // Install all available non-testing themes.
     $listing = new ExtensionDiscovery(\Drupal::root());
     $this->themes = $listing->scan('theme', FALSE);
     \Drupal::service('theme_handler')->install(array_keys($this->themes));
     // Create a test user.
     $this->user = $this->drupalCreateUser(array('access content', 'access user profiles'));
     $this->user->name = $this->xssLabel;
     $this->user->save();
     $this->drupalLogin($this->user);
     // Create a test term.
     $this->term = entity_create('taxonomy_term', array('name' => $this->xssLabel, 'vid' => 1));
     $this->term->save();
     // Add a comment field.
     $this->addDefaultCommentField('node', 'article', 'comment', CommentItemInterface::OPEN);
     // Create a test node tagged with the test term.
     $this->node = $this->drupalCreateNode(array('title' => $this->xssLabel, 'type' => 'article', 'promote' => NODE_PROMOTED, 'field_tags' => array(array('target_id' => $this->term->id()))));
     // Create a test comment on the test node.
     $this->comment = entity_create('comment', array('entity_id' => $this->node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'status' => CommentInterface::PUBLISHED, 'subject' => $this->xssLabel, 'comment_body' => array($this->randomMachineName())));
     $this->comment->save();
 }