Deliver additive INE demography and authenticated homologation installation
tests / ci (push) Waiting to run
tests / ci (push) Waiting to run
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Services\DemographicInstallation;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
final class DemographicTargetTest extends TestCase
|
||||
{
|
||||
public function test_homologation_requires_activation_exact_url_and_actual_database_identity(): void
|
||||
{
|
||||
app()->instance('env', 'production');
|
||||
config(['app.url' => 'https://teste-investidor.tempo.co.mz', 'demography.enabled' => true,
|
||||
'database.default' => 'pgsql', 'database.connections.pgsql.host' => '127.0.0.1',
|
||||
'database.connections.pgsql.port' => 5432, 'database.connections.pgsql.database' => 'teste_investidor',
|
||||
'database.connections.pgsql.url' => null]);
|
||||
DB::shouldReceive('selectOne')->twice()->with('SELECT current_database() AS database,inet_server_port() AS port')
|
||||
->andReturn((object) ['database' => 'teste_investidor', 'port' => 5432], (object) ['database' => 'other_database', 'port' => 5432]);
|
||||
$service = app(DemographicInstallation::class);
|
||||
$this->assertTrue($service->activeTarget());
|
||||
$this->assertFalse($service->activeTarget());
|
||||
config(['demography.enabled' => false]);
|
||||
$this->assertFalse($service->activeTarget());
|
||||
config(['demography.enabled' => true, 'app.url' => 'https://other.example']);
|
||||
$this->assertFalse($service->activeTarget());
|
||||
config(['app.url' => 'https://teste-investidor.tempo.co.mz', 'database.connections.pgsql.host' => 'remote.example']);
|
||||
$this->assertFalse($service->activeTarget());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user