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()); } public function test_the_public_domain_is_the_same_production_installation(): void { // Production answers on investemoz.tempo.co.mz; moving APP_URL there must not disable the installation. app()->instance('env', 'production'); config(['app.url' => 'https://investemoz.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')->once()->with('SELECT current_database() AS database,inet_server_port() AS port') ->andReturn((object) ['database' => 'teste_investidor', 'port' => 5432]); $this->assertTrue(app(DemographicInstallation::class)->activeTarget()); config(['app.url' => 'https://investemoz.tempo.co.mz.example']); $this->assertFalse(app(DemographicInstallation::class)->activeTarget()); } }