FieldTokensPropertyTest.php in Field tokens 8
File
src/Tests/FieldTokensPropertyTest.php
View source
<?php
namespace Drupal\field_tokens\Tests;
use Drupal\node\Entity\Node;
class FieldTokensPropertyTest extends FieldTokensTestBase {
public function testPropertyTokens() {
$test_image = current($this
->drupalGetTestFiles('image'));
$nid = $this
->uploadNodeImage($test_image, $this->field
->get('field_name'), $this->contentType
->id(), $this
->randomString());
$node = Node::load($nid);
$token = "[node:{$this->field->get('field_name')}-property:0:target_id]";
$value = \Drupal::service('token')
->replace($token, [
'node' => $node,
]);
$this
->assertEqual($value, $node->{$this->field
->get('field_name')}[0]->target_id, $token . ' matches provided Image field target_id property.');
}
}