class UserProtectionBaseUnitTest in User protect 8
@coversDefaultClass \Drupal\userprotect\Plugin\UserProtection\UserProtectionBase @group userprotect
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\userprotect\Unit\Plugin\UserProtection\UserProtectionBaseUnitTest
Expanded class hierarchy of UserProtectionBaseUnitTest
File
- tests/
src/ Unit/ Plugin/ UserProtection/ UserProtectionBaseUnitTest.php, line 11
Namespace
Drupal\Tests\userprotect\Unit\Plugin\UserProtectionView source
class UserProtectionBaseUnitTest extends UnitTestCase {
/**
* The module handler used for testing.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The userprotect method plugin under test.
*
* @var \Drupal\userprotect\Plugin\UserProtection\Mail
*/
protected $plugin;
/**
* The definition of the user protection plugin under test.
*
* @var array
*/
protected $pluginDefinition = [
'id' => 'dummy',
'label' => 'Dummy',
'description' => 'This is a dummy plugin definition.',
'provider' => '',
'status' => FALSE,
];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->moduleHandler = $this
->createMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
$this->plugin = $this
->getMockBuilder('\\Drupal\\userprotect\\Plugin\\UserProtection\\UserProtectionBase')
->setConstructorArgs([
[],
'',
$this->pluginDefinition,
$this->moduleHandler,
])
->setMethods([
't',
])
->getMock();
$this->plugin
->expects($this
->any())
->method('t')
->will($this
->returnArgument(0));
}
/**
* @covers ::label
*/
public function testLabel() {
$this
->assertSame('Dummy', $this->plugin
->label());
}
/**
* @covers ::description
*/
public function testDescription() {
$this
->assertSame('This is a dummy plugin definition.', $this->plugin
->description());
}
/**
* @covers ::setConfiguration
* @covers ::getConfiguration
*/
public function testGetConfiguration() {
$configuration = [
'status' => TRUE,
];
$this
->assertInstanceOf('\\Drupal\\userprotect\\Plugin\\UserProtection\\UserProtectionInterface', $this->plugin
->setConfiguration($configuration));
$saved_configuration = $this->plugin
->getConfiguration();
$this
->assertSame($configuration['status'], $saved_configuration['status']);
}
/**
* @covers ::defaultConfiguration
*/
public function testDefaultConfiguration() {
$this
->assertIsArray($this->plugin
->defaultConfiguration());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UserProtectionBaseUnitTest:: |
protected | property | The module handler used for testing. | |
UserProtectionBaseUnitTest:: |
protected | property | The userprotect method plugin under test. | |
UserProtectionBaseUnitTest:: |
protected | property | The definition of the user protection plugin under test. | |
UserProtectionBaseUnitTest:: |
public | function |
Overrides UnitTestCase:: |
|
UserProtectionBaseUnitTest:: |
public | function | @covers ::defaultConfiguration | |
UserProtectionBaseUnitTest:: |
public | function | @covers ::description | |
UserProtectionBaseUnitTest:: |
public | function | @covers ::setConfiguration @covers ::getConfiguration | |
UserProtectionBaseUnitTest:: |
public | function | @covers ::label |