<?php/**
* @file
* Definition of Drupal\system\Tests\Plugin\AlterDecoratorTest.
*/namespaceDrupal\system\Tests\Plugin;
useDrupal\Component\Plugin\Exception\ExceptionInterface;
useDrupal\plugin_test\Plugin\AlterDecoratorTestPluginManager;
useDrupal\plugin_test\Plugin\TestPluginManager;
useDrupal\simpletest\WebTestBase;
/**
* Tests that the AlterDecorator fires and respects the alter hook.
*/class AlterDecoratorTestextends 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 functiongetInfo() {
returnarray(
'name' => 'AlterDecorator',
'description' => 'Tests that the AlterDecorator fires and respects the alter hook.',
'group' => 'Plugin API',
);
}
public functionsetUp() {
parent::setUp();
// Setup a plugin manager which uses the alter decorator.$this->alterTestPluginManager = newAlterDecoratorTestPluginManager();
}
/**
* Tests getDefinitions() and getDefinition() of Drupal\Core\Plugin\Discovery\AlterDecorator.
*/
public functiontestAlterDecorator() {
// 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']);
}
}