Newer
Older
<?php
/**
* @file
* Contains \Drupal\Tests\Component\Plugin\PluginBaseTest.
*/
namespace Drupal\Tests\Component\Plugin;
use Drupal\Core\PhpStorage\PhpStorageFactory;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
use Drupal\Tests\UnitTestCase;
/**
* Tests the plugin base.
*
* @group Drupal
*
* @see \Drupal\Component\Plugin\PluginBase
*/
class PluginBaseTest extends UnitTestCase {
public static function getInfo() {
return array(
'name' => 'Plugin base test',
'description' => 'Tests the plugin base',
'group' => 'Plugin',
);
}
/**
* Tests the getPluginId method.
*
* @dataProvider providerTestGetPluginId
*
* @see \Drupal\Component\Plugin\PluginBase::getPluginId()
*
*/
public function testGetPluginId($plugin_id, $expected) {
$plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array(
array(),
$plugin_id,
array(),
));
$this->assertEquals($expected, $plugin_base->getPluginId());
}
/**
* Returns test data for testGetPluginId().
*
* @return array
*/
public function providerTestGetPluginId() {
return array(
array('base_id', 'base_id'),
array('base_id:derivative', 'base_id:derivative'),
);
}
/**
* Tests the getBasePluginId method.
*
* @dataProvider providerTestGetBasePluginId
*
* @see \Drupal\Component\Plugin\PluginBase::getBasePluginId()
*/
public function testGetBasePluginId($plugin_id, $expected) {
$plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array(
array(),
$plugin_id,
array(),
));
$this->assertEquals($expected, $plugin_base->getBasePluginId());
}
/**
* Returns test data for testGetBasePluginId().
*
* @return array
*/
public function providerTestGetBasePluginId() {
return array(
array('base_id', 'base_id'),
array('base_id:derivative', 'base_id'),
);
}
/**
* Tests the getBasePluginId method.
*
* @dataProvider providerTestGetDerivativeId
*
* @see \Drupal\Component\Plugin\PluginBase::getBasePluginId()
*/
public function testGetDerivativeId($plugin_id = NULL, $expected = NULL) {
$plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array(
array(),
$plugin_id,
array(),
));
$this->assertEquals($expected, $plugin_base->getDerivativeId());
}
/**
* Returns test data for testGetBasePluginId().
*
* @return array
*/
public function providerTestGetDerivativeId() {
return array(
array('base_id', NULL),
array('base_id:derivative', 'derivative'),
);
}
/**
* Tests the getPluginDefinition method.
*
* @see \Drupal\Component\Plugin\PluginBase::getPluginDefinition()
*/
public function testGetPluginDefinition() {
$plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array(
array(),
'plugin_id',
array('value', array('key' => 'value')),
));
$this->assertEquals(array('value', array('key' => 'value')), $plugin_base->getPluginDefinition());
}
}