You are here

public function EncryptionProfileTest::testSetEncryptionMethod in Encrypt 8.3

Tests the setEncryptionMethod method.

@covers ::setEncryptionMethod

File

tests/src/Unit/Entity/EncryptionProfileTest.php, line 245

Class

EncryptionProfileTest
Unit tests for EncryptionProfile class.

Namespace

Drupal\Tests\encrypt\Unit\Entity

Code

public function testSetEncryptionMethod() {

  // Set up a mock for the EncryptionProfile class to mock some methods.
  $encryption_profile = $this
    ->getMockBuilder('\\Drupal\\encrypt\\Entity\\EncryptionProfile')
    ->setMethods([
    'getPluginCollection',
  ])
    ->disableOriginalConstructor()
    ->getMock();
  $this->pluginCollection
    ->expects($this
    ->once())
    ->method('addInstanceID');

  // Set up expectations for encryption profile.
  $encryption_profile
    ->expects($this
    ->any())
    ->method('getPluginCollection')
    ->will($this
    ->returnValue($this->pluginCollection));

  // Set up expectations for encryption method.
  $this->encryptionMethod
    ->expects($this
    ->any())
    ->method('getPluginId')
    ->will($this
    ->returnValue('test_encryption_method'));
  $encryption_profile
    ->setEncryptionMethod($this->encryptionMethod);
}