Patched to Drupal 8.4.8 level. See https://www.drupal.org/sa-core-2018-004 and patch...
[yaffs-website] / vendor / drupal / drupal-extension / spec / Drupal / DrupalExtension / Context / Initializer / DrupalAwareInitializerSpec.php
1 <?php
2
3 namespace spec\Drupal\DrupalExtension\Context\Initializer;
4
5 use Behat\Behat\Context\Context;
6
7 use Drupal\DrupalDriverManager;
8 use Drupal\DrupalExtension\Context\DrupalAwareInterface;
9
10 use Behat\Testwork\Call\CallCenter;
11 use Behat\Testwork\Environment\EnvironmentManager;
12 use Behat\Testwork\Hook\HookDispatcher;
13 use Behat\Testwork\Hook\HookRepository;
14
15 use PhpSpec\ObjectBehavior;
16 use Prophecy\Argument;
17
18 class DrupalAwareInitializerSpec extends ObjectBehavior
19 {
20     private $dispatcher;
21
22     function let(DrupalDriverManager $drupal)
23     {
24         $callCenter = new CallCenter();
25         $manager = new EnvironmentManager();
26         $repository = new HookRepository($manager);
27         // Cannot mock this class as it is marked as final.
28         $this->dispatcher = new HookDispatcher($repository, $callCenter);
29         $this->beConstructedWith($drupal, array(), $this->dispatcher);
30     }
31
32     function it_is_a_context_initializer()
33     {
34         $this->shouldHaveType('Behat\Behat\Context\Initializer\ContextInitializer');
35     }
36
37     function it_does_nothing_for_basic_contexts(Context $context)
38     {
39         $this->initializeContext($context);
40     }
41
42     function it_injects_drupal_and_parameters_and_dispatcher_in_drupal_aware_Contexts(DrupalAwareInterface $context, $drupal)
43     {
44         $context->setDispatcher($this->dispatcher)->shouldBeCAlled();
45         $context->setDrupal($drupal)->shouldBeCAlled();
46         $context->setDrupalParameters(array())->shouldBeCAlled();
47         $this->initializeContext($context);
48     }
49 }