UserProtectionBaseUnitTest.php in User protect 8
File
tests/src/Unit/Plugin/UserProtection/UserProtectionBaseUnitTest.php
View source
<?php
namespace Drupal\Tests\userprotect\Unit\Plugin\UserProtection;
use Drupal\Tests\UnitTestCase;
class UserProtectionBaseUnitTest extends UnitTestCase {
protected $moduleHandler;
protected $plugin;
protected $pluginDefinition = [
'id' => 'dummy',
'label' => 'Dummy',
'description' => 'This is a dummy plugin definition.',
'provider' => '',
'status' => FALSE,
];
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));
}
public function testLabel() {
$this
->assertSame('Dummy', $this->plugin
->label());
}
public function testDescription() {
$this
->assertSame('This is a dummy plugin definition.', $this->plugin
->description());
}
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']);
}
public function testDefaultConfiguration() {
$this
->assertIsArray($this->plugin
->defaultConfiguration());
}
}