Completed
Push — master ( c00544...97496e )
by Guy
12s
created

testExceptionThrownWhenDecryptionFails()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\MFA\Tests\Service;
4
5
use SilverStripe\Dev\SapphireTest;
6
use SilverStripe\MFA\Service\DefusePHPEncryptionAdapter;
7
8
class PHPEncryptionAdapterTest extends SapphireTest
9
{
10
    public function testEncryptAndDecrypt()
11
    {
12
        $adapter = new DefusePHPEncryptionAdapter();
13
14
        $cipher = $adapter->encrypt('Hello World', 'secretkey123');
15
        $this->assertNotEquals('Hello World', $cipher);
16
17
        $plaintext = $adapter->decrypt($cipher, 'secretkey123');
18
        $this->assertSame('Hello World', $plaintext);
19
    }
20
21
    /**
22
     * @expectedException \SilverStripe\MFA\Exception\EncryptionAdapterException
23
     */
24
    public function testExceptionThrownWhenDecryptionFails()
25
    {
26
        (new DefusePHPEncryptionAdapter())->decrypt('892g359gohsdf', '');
27
    }
28
}
29