forked from TheAlgorithms/PHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CiphersTest.php
executable file
·27 lines (23 loc) · 956 Bytes
/
CiphersTest.php
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
use PHPUnit\Framework\TestCase;
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/../../Ciphers/CaesarCipher.php';
require_once __DIR__ . '/../../Ciphers/XORCipher.php';
class CiphersTest extends TestCase
{
public function testCaesarCipher()
{
$this->assertEquals('Aopz pz h alza.', encrypt('This is a test.', 7));
$this->assertEquals('Aopz pz h alza.', encrypt('This is a test.', 7 + 26));
$this->assertEquals('This is a test.', decrypt('Aopz pz h alza.', 7));
$this->assertEquals('This is a test.', decrypt('Aopz pz h alza.', 7 + 26));
}
public function testXorCipher()
{
$input_str = "test@string";
$key = "test-key";
$invalid_key = "wrong-key";
$this->assertEquals($input_str, xorCipher(xorCipher($input_str, $key), $key));
$this->assertNotEquals($input_str, xorCipher(xorCipher($input_str, $key), $invalid_key));
}
}