5 use Drupal\Core\DependencyInjection\Container;
6 use Drupal\Core\Entity\EntityInterface;
11 use Drupal\node\Entity\Node;
12 use PHPUnit\Framework\TestCase;
13 use Symfony\Component\HttpFoundation\Request;
14 use Symfony\Component\HttpFoundation\RequestStack;
25 $this->expectExceptionMessage(
"We only work with nodes.");
27 $entity = (
new Chain($this))
28 ->add(EntityInterface::class,
"blah", NULL)
38 $this->expectExceptionMessage(
"We only work with data nodes.");
40 $node = (
new Chain($this))
41 ->add(Node::class,
"bundle",
"blah")
51 $container = (
new Chain($this))
52 ->add(Container::class,
"get", RequestStack::class)
53 ->add(RequestStack::class,
"getCurrentRequest", Request::class)
54 ->add(Request::class,
"getHost",
"dkan")
55 ->add(Request::class,
"getSchemeAndHttpHost",
"http://dkan")
58 \Drupal::setContainer($container);
60 $metadata = (object) [
62 "downloadURL" =>
"http://dkan/some/path/blah",
66 $options = (
new Options())
67 ->add(
'field_json_metadata', (
object) [
"value" => json_encode($metadata)])
68 ->add(
'field_data_type', (
object) [
"value" =>
"distribution"])
71 $nodeChain =
new Chain($this);
73 ->add(Node::class,
"bundle",
"data")
74 ->add(Node::class,
"get", $options)
75 ->add(Node::class,
"set", NULL,
"metadata")
79 $lifeCycle->presave();
81 $metadata = $nodeChain->getStoredInput(
"metadata");