-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimpleCryptTest.php
More file actions
27 lines (21 loc) · 919 Bytes
/
SimpleCryptTest.php
File metadata and controls
27 lines (21 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'SimpleCrypt.php';
class SimpleCryptTest extends PHPUnit_Framework_TestCase {
protected $simplecrypt;
private $original_string;
protected function setUp() {
$this->original_string = 'very important data';
$this->simplecrypt = new SimpleCrypt( 'tripledes', 'mysecretkey' );
}
public function testObjectInstantiation() {
$this->assertTrue( is_a( $this->simplecrypt, 'SimpleCrypt' ) );
}
public function testEncryptedStringIsIdentitalAfterDecryption() {
$enc = $this->simplecrypt->encrypt_data( $this->original_string );
$this->assertTrue( is_string( $enc ) );
$dec = $this->simplecrypt->decrypt_data( $enc );
$this->assertTrue( is_string( $dec ) );
$this->assertTrue( strncmp( $dec, $this->original_string, strlen($this->original_string)) == 0 );
}
}