This repository was archived by the owner on Apr 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathTestCase.php
77 lines (61 loc) · 1.98 KB
/
TestCase.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* tests/TestCase.php
*
* @package laravel-database-encryption
* @link https://github.com/austinheap/laravel-database-encryption
* @author Austin Heap <me@austinheap.com>
* @version v0.2.1
*/
namespace AustinHeap\Database\Encryption\Tests;
use AustinHeap\Database\Encryption\EncryptionFacade;
use AustinHeap\Database\Encryption\EncryptionServiceProvider;
use DB, RuntimeException, ReflectionClass;
use Orchestra\Testbench\TestCase as BaseTestCase;
/**
* TestCase
*/
class TestCase extends BaseTestCase
{
protected $last_random;
protected function getEnvironmentSetUp($app)
{
$app['config']->set('app.key', str_random(32));
$app['config']->set('database-encryption.enabled', true);
}
public static function callProtectedMethod($object, $method, array $args = [])
{
$class = new ReflectionClass(get_class($object));
$method = $class->getMethod($method);
$method->setAccessible(true);
return $method->invokeArgs($object, $args);
}
public function testTestCase()
{
$this->assertEquals('placeholder to silence phpunit warnings', 'placeholder to silence phpunit warnings');
}
protected function newRandomFromArray(array $array)
{
return $this->newRandom($array);
}
protected function newRandom($value)
{
if (is_array($value)) {
$value = array_random($value);
}
$this->last_random = is_string($value) ? sprintf($value, (string)rand(1111, 9999)) : $value;
return $this->last_random;
}
protected function currentRandom()
{
return $this->last_random;
}
protected function getPackageProviders($app)
{
return array_merge(parent::getPackageProviders($app), [EncryptionServiceProvider::class]);
}
protected function getPackageAliases($app)
{
return array_merge(parent::getPackageAliases($app), ['DatabaseEncryption' => EncryptionFacade::class]);
}
}