5 use MockChain\Sequence;
6 use Drupal\Core\Config\ConfigFactory;
7 use Drupal\Core\Config\ImmutableConfig;
8 use Drupal\Core\Entity\EntityStorageInterface;
9 use Drupal\Core\Entity\EntityTypeManager;
11 use Drupal\node\Entity\Node;
13 use PHPUnit\Framework\TestCase;
24 $node = (
new Chain($this))
25 ->add(Node::class,
"uuid",
"123456789")
28 $entityTypeManager = (
new Chain($this))
29 ->add(EntityTypeManager::class,
'getStorage', EntityStorageInterface::class)
30 ->add(EntityStorageInterface::class,
'loadByProperties', [$node])
33 $configService = (
new Chain($this))
34 ->add(ConfigFactory::class,
'get', ImmutableConfig::class)
35 ->add(ImmutableConfig::class,
'get', [
'publisher'])
38 $valueReferencer =
new Referencer($configService, $entityTypeManager);
39 $referenced = $valueReferencer->reference((
object) [
'publisher' => (
object) [
'name' =>
'Gerardo',
'company' =>
'CivicActions']]);
41 $this->assertTrue(is_object($referenced));
42 $this->assertEquals(
"123456789", $referenced->publisher);
49 $uuids = (
new Sequence())
53 $node = (
new Chain($this))
54 ->add(Node::class,
"uuid", $uuids)
57 $entityTypeManager = (
new Chain($this))
58 ->add(EntityTypeManager::class,
'getStorage', EntityStorageInterface::class)
59 ->add(EntityStorageInterface::class,
'loadByProperties', [$node])
62 $configService = (
new Chain($this))
63 ->add(ConfigFactory::class,
'get', ImmutableConfig::class)
64 ->add(ImmutableConfig::class,
'get', [
'keyword'])
67 $valueReferencer =
new Referencer($configService, $entityTypeManager);
68 $referenced = $valueReferencer->reference((
object) [
'keyword' => [
'Gerardo',
'CivicActions']]);
70 $this->assertTrue(is_object($referenced));
71 $this->assertEquals(
"123456789", $referenced->keyword[0]);
72 $this->assertEquals(
"987654321", $referenced->keyword[1]);