Newer
Older
<?php
/**
* @file
Angie Byron
committed
* Contains \Drupal\system\Tests\Plugin\AlterDecoratorTest.
6
7
8
9
10
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
*/
namespace Drupal\system\Tests\Plugin;
use Drupal\Component\Plugin\Exception\ExceptionInterface;
use Drupal\plugin_test\Plugin\AlterDecoratorTestPluginManager;
use Drupal\plugin_test\Plugin\TestPluginManager;
use Drupal\simpletest\WebTestBase;
/**
* Tests that the AlterDecorator fires and respects the alter hook.
*/
class AlterDecoratorTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('plugin_test');
/**
* Stores a plugin manager which uses the AlterDecorator.
*
* @var Drupal\plugin_test\Plugin\AlterDecoratorTestPluginManager;
*/
protected $alterTestPluginManager;
public static function getInfo() {
return array(
'name' => 'AlterDecorator',
'description' => 'Tests that the AlterDecorator fires and respects the alter hook.',
'group' => 'Plugin API',
);
}
public function setUp() {
parent::setUp();
// Setup a plugin manager which uses the alter decorator.
$this->alterTestPluginManager = new AlterDecoratorTestPluginManager();
}
/**
* Tests getDefinitions() and getDefinition() of Drupal\Core\Plugin\Discovery\AlterDecorator.
*/
public function testAlterDecorator() {
// Ensure that getDefinitions() fires and changes the actual plugin definitions.
$definitions = $this->alterTestPluginManager->getDefinitions();
foreach ($definitions as &$definition) {
$this->assertTrue($definition['altered']);
}
// Ensure that getDefinitions() fires and changes the actual plugin definition.
$definition = $this->alterTestPluginManager->getDefinition('user_login');
$this->assertTrue($definition['altered_single']);
}
}