class WebformNodeUninstallValidatorTest in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_node/tests/src/Unit/WebformNodeUninstallValidatorTest.php \Drupal\Tests\webform_node\Unit\WebformNodeUninstallValidatorTest
@coversDefaultClass \Drupal\webform_node\WebformNodeUninstallValidator @group webform_node
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\webform_node\Unit\WebformNodeUninstallValidatorTest
Expanded class hierarchy of WebformNodeUninstallValidatorTest
File
- modules/
webform_node/ tests/ src/ Unit/ WebformNodeUninstallValidatorTest.php, line 11
Namespace
Drupal\Tests\webform_node\UnitView source
class WebformNodeUninstallValidatorTest extends UnitTestCase {
/**
* A mock webform node uninstall validator.
*
* @var \Drupal\webform_node\WebformNodeUninstallValidator|\PHPUnit_Framework_MockObject_MockObject
*/
protected $webformNodeUninstallValidator;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->webformNodeUninstallValidator = $this
->getMockBuilder('Drupal\\webform_node\\WebformNodeUninstallValidator')
->disableOriginalConstructor()
->setMethods([
'hasWebformNodes',
])
->getMock();
$this->webformNodeUninstallValidator
->setStringTranslation($this
->getStringTranslationStub());
}
/**
* @covers ::validate
*/
public function testValidateNotWebformNode() {
$this->webformNodeUninstallValidator
->expects($this
->never())
->method('hasWebformNodes');
$module = 'not_webform_node';
$expected = [];
$reasons = $this->webformNodeUninstallValidator
->validate($module);
$this
->assertEquals($expected, $reasons);
}
/**
* @covers ::validate
*/
public function testValidateEntityQueryWithoutResults() {
$this->webformNodeUninstallValidator
->expects($this
->once())
->method('hasWebformNodes')
->willReturn(FALSE);
$module = 'webform_node';
$expected = [];
$reasons = $this->webformNodeUninstallValidator
->validate($module);
$this
->assertEquals($expected, $reasons);
}
/**
* @covers ::validate
*/
public function testValidateEntityQueryWithResults() {
$this->webformNodeUninstallValidator
->expects($this
->once())
->method('hasWebformNodes')
->willReturn(TRUE);
$module = 'webform_node';
$expected = [
'To uninstall Webform node, delete all content that has the Webform content type.',
];
$reasons = $this->webformNodeUninstallValidator
->validate($module);
$this
->assertEquals($expected, $reasons);
}
}
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. | |
WebformNodeUninstallValidatorTest:: |
protected | property | A mock webform node uninstall validator. | |
WebformNodeUninstallValidatorTest:: |
protected | function |
Overrides UnitTestCase:: |
|
WebformNodeUninstallValidatorTest:: |
public | function | @covers ::validate | |
WebformNodeUninstallValidatorTest:: |
public | function | @covers ::validate | |
WebformNodeUninstallValidatorTest:: |
public | function | @covers ::validate |