Completed
Push — 1.0.x ( 54cff8...fde7fe )
by Antonio
06:25
created

RawMinkContext::setContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace NuvoleWeb\Drupal\DrupalExtension\Context;
4
5
use Behat\Mink\Element\NodeElement;
6
use Behat\Mink\Exception\ExpectationException;
7
use Behat\MinkExtension\Context\RawMinkContext as OriginalRawMinkContext;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
10
/**
11
 * Class RawMinkContext.
12
 *
13
 * @package NuvoleWeb\Drupal\DrupalExtension\Context
14
 */
15
class RawMinkContext extends OriginalRawMinkContext implements ServiceContainerAwareInterface {
16
17
  /**
18
   * Service container instance.
19
   *
20
   * @var ContainerBuilder
21
   */
22
  private $container;
23
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function setContainer(ContainerBuilder $container) {
28
    $this->container = $container;
29
  }
30
31
  /**
32
   * {@inheritdoc}
33
   */
34
  public function getContainer() {
35
    return $this->container;
36
  }
37
38
  /**
39
   * Checks that the given element is of the given type.
40
   *
41
   * @param NodeElement $element
42
   *   The element to check.
43
   * @param string $type
44
   *   The expected type.
45
   *
46
   * @throws ExpectationException
47
   *   Thrown when the given element is not of the expected type.
48
   */
49
  public function assertElementType(NodeElement $element, $type) {
50
    if ($element->getTagName() !== $type) {
51
      throw new ExpectationException("The element is not a '$type'' field.", $this->getSession());
52
    }
53
  }
54
55
}
56