Skip to content

Commit

Permalink
tests(encryption): add testEncryptDataFailed
Browse files Browse the repository at this point in the history
  • Loading branch information
doyouhaobaby committed Nov 1, 2020
1 parent 2a495c3 commit 06ad7e9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Encryption/EncryptionTest.php
Expand Up @@ -341,4 +341,25 @@ public function testValidateSignFailed(): void
$sign = '';
$this->invokeTestMethod($encryption, 'validateSign', [$data, $sign]);
}

public function testEncryptDataFailed(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage(
'Encrypt the data failed.'
);

$GLOBALS['RUNTIME_ERROR_REPORTING'] = error_reporting();
error_reporting(0);

$encryption = new Encryption(
'encode-key',
'AES-256-CBC'
);

$value = 'data';
$iv = $this->invokeTestMethod($encryption, 'createIv');
$this->setTestProperty($encryption, 'cipher', 11);
$this->invokeTestMethod($encryption, 'encryptData', [$value, $iv]);
}
}

0 comments on commit 06ad7e9

Please sign in to comment.