Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Drupal\Tests\token\Kernel;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\taxonomy\VocabularyInterface;
|
||||
|
||||
|
@ -55,20 +55,21 @@ class EntityTest extends KernelTestBase {
|
|||
$this->assertIdentical($mapper->getTokenTypeForEntityType('invalid'), FALSE);
|
||||
$this->assertIdentical($mapper->getTokenTypeForEntityType('invalid', TRUE), 'invalid');
|
||||
|
||||
// Test that when we send the mis-matched entity type into token_replace()
|
||||
// that we still get the tokens replaced.
|
||||
$vocabulary = entity_load('taxonomy_vocabulary', 'tags');
|
||||
// Test that when we send the mis-matched entity type into
|
||||
// Drupal\Core\Utility\Token::replace() that we still get the tokens
|
||||
// replaced.
|
||||
$vocabulary = Vocabulary::load('tags');
|
||||
$term = $this->addTerm($vocabulary);
|
||||
$this->assertIdentical(\Drupal::token()->replace('[vocabulary:name]', array('taxonomy_vocabulary' => $vocabulary)), $vocabulary->label());
|
||||
$this->assertIdentical(\Drupal::token()->replace('[term:name][term:vocabulary:name]', array('taxonomy_term' => $term)), $term->label() . $vocabulary->label());
|
||||
$this->assertIdentical(\Drupal::token()->replace('[vocabulary:name]', ['taxonomy_vocabulary' => $vocabulary]), $vocabulary->label());
|
||||
$this->assertIdentical(\Drupal::token()->replace('[term:name][term:vocabulary:name]', ['taxonomy_term' => $term]), $term->label() . $vocabulary->label());
|
||||
}
|
||||
|
||||
function addTerm(VocabularyInterface $vocabulary, array $term = array()) {
|
||||
$term += array(
|
||||
'name' => Unicode::strtolower($this->randomMachineName(5)),
|
||||
function addTerm(VocabularyInterface $vocabulary, array $term = []) {
|
||||
$term += [
|
||||
'name' => mb_strtolower($this->randomMachineName(5)),
|
||||
'vid' => $vocabulary->id(),
|
||||
);
|
||||
$term = entity_create('taxonomy_term', $term);
|
||||
];
|
||||
$term = Term::create($term);
|
||||
$term->save();
|
||||
return $term;
|
||||
}
|
||||
|
@ -80,25 +81,26 @@ class EntityTest extends KernelTestBase {
|
|||
$node = Node::create(['type' => 'page', 'title' => 'Original title']);
|
||||
$node->save();
|
||||
|
||||
$tokens = array(
|
||||
$tokens = [
|
||||
'nid' => $node->id(),
|
||||
'title' => 'Original title',
|
||||
'original' => NULL,
|
||||
'original:nid' => NULL,
|
||||
);
|
||||
$this->assertTokens('node', array('node' => $node), $tokens);
|
||||
];
|
||||
$this->assertTokens('node', ['node' => $node], $tokens);
|
||||
|
||||
// Emulate the original entity property that would be available from
|
||||
// node_save() and change the title for the node.
|
||||
$node->original = entity_load_unchanged('node', $node->id());
|
||||
$node->original = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($node->id());
|
||||
$node->title = 'New title';
|
||||
|
||||
$tokens = array(
|
||||
$tokens = [
|
||||
'nid' => $node->id(),
|
||||
'title' => 'New title',
|
||||
'original' => 'Original title',
|
||||
'original:nid' => $node->id(),
|
||||
);
|
||||
$this->assertTokens('node', array('node' => $node), $tokens);
|
||||
];
|
||||
$this->assertTokens('node', ['node' => $node], $tokens);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue