public function EncryptionProfileTest::testGetEncryptionKey in Encrypt 8.3
Tests the getEncryptionKey method.
@covers ::getEncryptionKey
File
- tests/
src/ Unit/ Entity/ EncryptionProfileTest.php, line 273
Class
- EncryptionProfileTest
- Unit tests for EncryptionProfile class.
Namespace
Drupal\Tests\encrypt\Unit\EntityCode
public function testGetEncryptionKey() {
// Set up a mock for the EncryptionProfile class to mock some methods.
$encryption_profile = $this
->getMockBuilder('\\Drupal\\encrypt\\Entity\\EncryptionProfile')
->setMethods([
'getKeyRepository',
'getEncryptionKeyId',
])
->disableOriginalConstructor()
->getMock();
$this->keyRepository
->expects($this
->any())
->method('getKey')
->with($this
->equalTo('test_key'))
->will($this
->returnValue($this->key));
$encryption_profile
->expects($this
->any())
->method('getKeyRepository')
->will($this
->returnValue($this->keyRepository));
$encryption_profile
->expects($this
->any())
->method('getEncryptionKeyId')
->will($this
->returnValue('test_key'));
$result = $encryption_profile
->getEncryptionKey();
$this
->assertInstanceOf(KeyInterface::class, $result);
}