|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Wazza\DbEncrypt\Tests; |
| 4 | + |
| 5 | +use Orchestra\Testbench\TestCase as OrchestraTestCase; |
| 6 | +use Illuminate\Foundation\Testing\DatabaseMigrations; |
| 7 | +use Illuminate\Foundation\Testing\DatabaseTransactions; |
| 8 | +use Wazza\DbEncrypt\Providers\DbEncryptServiceProvider; |
| 9 | +use Wazza\DbEncrypt\Models\EncryptedAttributes; |
| 10 | + |
| 11 | +abstract class TestCase extends OrchestraTestCase |
| 12 | +{ |
| 13 | + use DatabaseMigrations, DatabaseTransactions; |
| 14 | + |
| 15 | + /** |
| 16 | + * Setup the test environment. |
| 17 | + * |
| 18 | + * @return void |
| 19 | + */ |
| 20 | + protected function setUp(): void |
| 21 | + { |
| 22 | + parent::setUp(); |
| 23 | + |
| 24 | + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
| 25 | + // $this->withFactories(__DIR__ . '/../database/factories'); |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Add the package provider |
| 30 | + * |
| 31 | + * @param $app |
| 32 | + * @return array |
| 33 | + */ |
| 34 | + protected function getPackageProviders($app) |
| 35 | + { |
| 36 | + return [ |
| 37 | + DbEncryptServiceProvider::class, |
| 38 | + ]; |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Define environment setup. |
| 43 | + * |
| 44 | + * @param \Illuminate\Foundation\Application $app |
| 45 | + * @return void |
| 46 | + */ |
| 47 | + protected function getEnvironmentSetUp($app) |
| 48 | + { |
| 49 | + $app['config']->set('database.default', 'testdb'); |
| 50 | + $app['config']->set('database.connections.testdb', [ |
| 51 | + 'driver' => 'sqlite', |
| 52 | + 'database' => __DIR__ . '/testdb.sqlite', |
| 53 | + 'prefix' => '', |
| 54 | + ]); |
| 55 | + $app['config']->set('db-encrypt.db.primary_key_format', env('DB_ENCRYPT_DB_PRIMARY_KEY_FORMAT', 'int')); |
| 56 | + $app['config']->set('db-encrypt.logging.level', env('DB_ENCRYPT_LOG_LEVEL')); |
| 57 | + $app['config']->set('db-encrypt.logging.indicator', env('DB_ENCRYPT_LOG_INDICATOR')); |
| 58 | + $app['config']->set('db-encrypt.key', env('DB_ENCRYPT_KEY')); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Define aliases for the package |
| 63 | + */ |
| 64 | + protected function getPackageAliases($app) |
| 65 | + { |
| 66 | + return [ |
| 67 | + 'config' => 'Illuminate\Config\Repository' |
| 68 | + ]; |
| 69 | + } |
| 70 | +} |
0 commit comments