aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWilly Micieli <micieli@laposte.net>2019-09-21 19:29:53 +0200
committerWilly Micieli <micieli@laposte.net>2019-09-21 19:29:53 +0200
commit5b8ba8aa1b62816a8c171e1f2450c54210c71411 (patch)
tree2c29ed863df84855d4259801716a4da7ead75e51 /tests
parent16764027712eacc117176ffb6be7079201e8ac4d (diff)
downloadimperium-5b8ba8aa1b62816a8c171e1f2450c54210c71411.zip
imperium-5b8ba8aa1b62816a8c171e1f2450c54210c71411.tar.gz
add crypt class and add env method to all controllers
Diffstat (limited to 'tests')
-rw-r--r--tests/Crypt/CryptTest.php24
-rw-r--r--tests/FileTest.php8
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/Crypt/CryptTest.php b/tests/Crypt/CryptTest.php
new file mode 100644
index 0000000..f928635
--- /dev/null
+++ b/tests/Crypt/CryptTest.php
@@ -0,0 +1,24 @@
+<?php
+
+ namespace Testing\Crypt
+ {
+
+ use Imperium\Encrypt\Crypt;
+ use Imperium\Testing\Unit;
+
+ class CryptTest extends Unit
+ {
+
+ public function test_generate_key()
+ {
+ $this->assertNotEmpty(Crypt::generateKey());
+ }
+
+
+ public function test_encrypt_and_decryt()
+ {
+ $this->assertNotEmpty($this->crypt()->encrypt('ALEX'));
+ $this->assertEquals('ALEX',$this->crypt()->decrypt($this->crypt()->encrypt('ALEX')));
+ }
+ }
+ } \ No newline at end of file
diff --git a/tests/FileTest.php b/tests/FileTest.php
index 388716d..e29d2e4 100644
--- a/tests/FileTest.php
+++ b/tests/FileTest.php
@@ -4,6 +4,7 @@
namespace Testing;
+use Imperium\Encrypt\Crypt;
use Imperium\Exception\Kedavra;
use Imperium\File\File;
use Imperium\Testing\Unit;
@@ -258,9 +259,16 @@ class FileTest extends Unit
$this->assertTrue($this->file('.env.example')->copy('.env'));
$this->assertEquals('Shaolin',env('app'));
$this->assertTrue($this->file('.env')->remove());
+
$this->assertTrue($this->file('.env.example')->copy('.env'));
$this->assertEquals('Shaolin',env('app'));
+ $this->assertTrue($this->file('.env')->remove());
+
+ $this->assertTrue($this->file('.env.example')->copy('.env'));
+ $key = Crypt::generateKey();
+ $this->assertTrue($this->file('.env',EMPTY_AND_WRITE_FILE_MODE)->write("APP_KEY=$key")->flush());
}
+
/**
* @throws Kedavra
*/