WebformNodeUninstallValidatorTest.php in Webform 8.5
File
modules/webform_node/tests/src/Unit/WebformNodeUninstallValidatorTest.php
View source
<?php
namespace Drupal\Tests\webform_node\Unit;
use Drupal\Tests\UnitTestCase;
class WebformNodeUninstallValidatorTest extends UnitTestCase {
protected $webformNodeUninstallValidator;
protected function setUp() {
parent::setUp();
$this->webformNodeUninstallValidator = $this
->getMockBuilder('Drupal\\webform_node\\WebformNodeUninstallValidator')
->disableOriginalConstructor()
->setMethods([
'hasWebformNodes',
])
->getMock();
$this->webformNodeUninstallValidator
->setStringTranslation($this
->getStringTranslationStub());
}
public function testValidateNotWebformNode() {
$this->webformNodeUninstallValidator
->expects($this
->never())
->method('hasWebformNodes');
$module = 'not_webform_node';
$expected = [];
$reasons = $this->webformNodeUninstallValidator
->validate($module);
$this
->assertEquals($expected, $reasons);
}
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);
}
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);
}
}