| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use Orchestra\Testbench\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Dimsav\Translatable\Test\Model\Country; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | class TestsBase extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |     protected $queriesCount; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     protected static $db2Setup = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     const DB_NAME = 'translatable_test'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     const DB_NAME2 = 'translatable_test2'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     const DB_USERNAME = 'homestead'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     const DB_PASSWORD = 'secret'; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     protected function setUp(): void | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |         parent::setUp(); | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |         $this->migrate('mysql'); | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |         $this->refreshSeedData(); | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     protected function refreshSeedData() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $seeder = new AddFreshSeeds; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $seeder->run(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     protected function migrate($dbConnectionName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $migrationsPath = '../../../../tests/migrations'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $artisan = $this->app->make(\Illuminate\Contracts\Console\Kernel::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         // Makes sure the migrations table is created | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $artisan->call('migrate:fresh', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             '--database' => $dbConnectionName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             '--path'     => $migrationsPath, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     public function testRunningMigration() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $country = Country::find(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $this->assertEquals('gr', $country->code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     protected function getPackageProviders($app) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             \Dimsav\Translatable\TranslatableServiceProvider::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     protected function getEnvironmentSetUp($app) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $app['path.base'] = __DIR__.'/..'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $app['config']->set('database.default', 'mysql'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $app['config']->set('database.connections.mysql', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             'driver'   => 'mysql', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             'host' => '127.0.0.1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             'database' => static::DB_NAME, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             'username' => static::DB_USERNAME, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             'password' => static::DB_PASSWORD, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             'charset' => 'utf8', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             'collation' => 'utf8_unicode_ci', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             'strict' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $app['config']->set('database.connections.mysql2', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             'driver'   => 'mysql', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             'host' => '127.0.0.1', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             'database' => static::DB_NAME2, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             'username' => static::DB_USERNAME, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             'password' => static::DB_PASSWORD, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             'charset' => 'utf8', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             'collation' => 'utf8_unicode_ci', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             'strict' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $locales = ['el', 'en', 'fr', 'de', 'id', 'en-GB', 'en-US', 'de-DE', 'de-CH']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $app['config']->set('translatable.locales', $locales); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 82 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 83 |  |  |  |