protected function EncryptionProfileTest::setUp in Encrypt 8.3
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ Entity/ EncryptionProfileTest.php, line 53
Class
- EncryptionProfileTest
- Unit tests for EncryptionProfile class.
Namespace
Drupal\Tests\encrypt\Unit\EntityCode
protected function setUp() {
parent::setUp();
$container = new ContainerBuilder();
$container
->set('string_translation', $this
->getStringTranslationStub());
\Drupal::setContainer($container);
// Mock a Key entity.
$this->key = $this
->getMockBuilder('\\Drupal\\key\\Entity\\Key')
->disableOriginalConstructor()
->getMock();
// Set up expectations for key.
$key_type = $this
->getMockBuilder('\\Drupal\\key\\Plugin\\KeyType\\EncryptionKeyType')
->disableOriginalConstructor()
->getMock();
$key_type
->expects($this
->any())
->method('getPluginId')
->will($this
->returnValue('encryption'));
$this->key
->expects($this
->any())
->method('getKeyType')
->will($this
->returnValue($key_type));
$this->key
->expects($this
->any())
->method('getKeyValue')
->will($this
->returnValue("key_value"));
// Mock an EncryptionMethod.
$this->encryptionMethod = $this
->getMockBuilder('\\Drupal\\encrypt\\EncryptionMethodInterface')
->disableOriginalConstructor()
->getMock();
// Set up expectations for encryption method.
$this->encryptionMethod
->expects($this
->any())
->method('checkDependencies')
->will($this
->returnValue([]));
// Mock a KeyRepository.
$this->keyRepository = $this
->getMockBuilder('\\Drupal\\key\\KeyRepository')
->disableOriginalConstructor()
->getMock();
// Mock a plugin collection.
$this->pluginCollection = $this
->getMockBuilder('\\Drupal\\Core\\Plugin\\DefaultLazyPluginCollection')
->disableOriginalConstructor()
->setMethods([
'get',
'set',
'addInstanceID',
])
->getMock();
}