aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilly Micieli <micieli@laposte.net>2019-11-07 16:20:41 +0100
committerWilly Micieli <micieli@laposte.net>2019-11-07 16:20:41 +0100
commit1b33a1f59896f92fdf170d9376b6e4b234e02385 (patch)
tree6eda4518201b7666da86a7ee0a6dafa2944cf3f6
parentd71fd5871a15e8f2f3879ca5094997b654cabf85 (diff)
downloadimperium-1b33a1f59896f92fdf170d9376b6e4b234e02385.zip
imperium-1b33a1f59896f92fdf170d9376b6e4b234e02385.tar.gz
add missing tests
-rw-r--r--imperium/Testing/Unit.php24
-rw-r--r--tests/AppTest.php22
2 files changed, 38 insertions, 8 deletions
diff --git a/imperium/Testing/Unit.php b/imperium/Testing/Unit.php
index 487b62f..440dba7 100644
--- a/imperium/Testing/Unit.php
+++ b/imperium/Testing/Unit.php
@@ -6,7 +6,8 @@
use DI\DependencyException;
use DI\NotFoundException;
use GuzzleHttp\Psr7\ServerRequest;
- use Imperium\Cache\Cache;
+ use Imperium\App;
+ use Imperium\Cache\Cache;
use Imperium\Collection\Collect;
use Imperium\Cookies\Cookies;
use Imperium\Encrypt\Crypt;
@@ -52,6 +53,21 @@
/**
*
+ * Get app instance
+ *
+ * @return App
+ *
+ * @throws DependencyException
+ * @throws NotFoundException
+ *
+ */
+ public function app(): App
+ {
+ return app();
+ }
+
+ /**
+ *
* Get an instance of cookies
*
* @return Cookies
@@ -73,7 +89,6 @@
*/
public function collect(array $data = []) : Collect
{
-
return collect($data);
}
@@ -91,7 +106,7 @@
*/
public function validate(array $data): Validator
{
- return new Validator($this->collect($data));
+ return app()->validator($data);
}
/**
@@ -125,7 +140,6 @@
*/
public function write(string $subject, string $message, string $author_email, string $to) : Write
{
-
return new Write($subject, $message, $author_email, $to);
}
@@ -138,7 +152,6 @@
*/
public function cache() : Cache
{
-
return new Cache();
}
@@ -169,6 +182,7 @@
*
* @throws DependencyException
* @throws NotFoundException
+ * @throws Kedavra
*
*/
public function git(string $repository,string $owner): Git
diff --git a/tests/AppTest.php b/tests/AppTest.php
index 438545d..6a204b6 100644
--- a/tests/AppTest.php
+++ b/tests/AppTest.php
@@ -8,16 +8,18 @@
use Imperium\File\File;
use Imperium\Html\Form\Form;
use Imperium\Query\Query;
- use Imperium\Security\Auth\Oauth;
+ use Imperium\Redis\Redis;
+ use Imperium\Security\Auth\Oauth;
use Imperium\Shopping\Shop;
use Imperium\Tables\Table;
- use Imperium\Writing\Write;
+ use Imperium\Testing\Unit;
+ use Imperium\Writing\Write;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
- class AppTest extends TestCase
+ class AppTest extends Unit
{
public function test()
{
@@ -34,12 +36,26 @@
$this->assertInstanceOf(RedirectResponse::class,app()->redirect('web','root'));
$this->assertInstanceOf(RedirectResponse::class,app()->back());
$this->assertInstanceOf(RedirectResponse::class,app()->to('/'));
+ $this->assertInstanceOf(Redis::class,app()->redis());
$this->assertInstanceOf(Cache::class,app()->cache());
$this->assertInstanceOf(Curl::class,app()->curl());
$this->assertInstanceOf(Shop::class,app()->shop());
$this->assertNotEmpty(app()->tables());
+ $this->assertNull(app()->post('a'));
+ $this->assertNull(app()->get('a'));
+ $this->assertNull(app()->cookie('a'));
+ $this->assertNull(app()->server('a'));
+ $this->assertNull(app()->files('a'));
$this->assertTrue(app()->save());
}
+
+ public function test_decrypt_and_encrypt()
+ {
+ $string = $this->app()->crypt('a');
+ $this->assertNotEquals('a',$string);
+ $this->assertEquals('a',$this->app()->decrypt($string));
+
+ }
} \ No newline at end of file