Completed
Pull Request — master (#157)
by
unknown
01:46
created

DriverEntityKernelTestBase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 45
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 18 2
1
<?php
2
3
namespace Drupal\Tests\Driver\Kernel\Drupal8\Entity;
4
5
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
6
use Drupal\Tests\Driver\Kernel\DriverKernelTestTrait;
7
use Drupal\Driver\Plugin\DriverFieldPluginManager;
8
use Drupal\Driver\Plugin\DriverEntityPluginManager;
9
10
/**
11
 * Base class for all Driver entity kernel tests.
12
 */
13
class DriverEntityKernelTestBase extends EntityKernelTestBase
14
{
15
16
    use DriverKernelTestTrait;
17
18
  /**
19
   * Machine name of the entity type being tested.
20
   *
21
   * @string
22
   */
23
    protected $entityType;
24
25
  /**
26
   * Entity storage.
27
   *
28
   * * @var \Drupal\Core\Entity\EntityStorageInterface;
29
   */
30
    protected $storage;
31
32
  /**
33
   * Absolute path to test project plugins.
34
   *
35
   * * @var string;
36
   */
37
    protected $projectPluginRoot;
38
39
    protected function setUp()
40
    {
41
        parent::setUp();
42
        $this->setUpDriver();
43
        if (empty($this->config)) {
44
            $this->storage = \Drupal::entityTypeManager()
45
            ->getStorage($this->entityType);
46
        }
47
48
        $namespaces = \Drupal::service('container.namespaces');
49
        $cache_backend = \Drupal::service('cache.discovery');
50
        $module_handler = \Drupal::service('module_handler');
51
52
        $reflection = new \ReflectionClass($this);
53
        $this->projectPluginRoot = dirname($reflection->getFileName(), 7) . "/test_project";
54
        $this->fieldPluginManager = new DriverFieldPluginManager($namespaces, $cache_backend, $module_handler, 8, $this->projectPluginRoot);
55
        $this->entityPluginManager = new DriverEntityPluginManager($namespaces, $cache_backend, $module_handler, 8, $this->projectPluginRoot);
56
    }
57
}
58