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

RawMinkContext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 41
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setContainer() 0 3 1
A getContainer() 0 3 1
A assertElementType() 0 5 2
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