-
-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Hi @mychidarko !
I have configured phpunit and pest in my leaf project, but with both libraries when I run the tests I get this error:
Database connection [default] not configured.
I have created the database.php file in the config folder but I still get an error.
This is the content of database.php:
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => _env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by eloquent is shown below to make development simple.
|
|
| All database work in eloquent is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'url' => _env('DATABASE_URL'),
'database' => _env('DB_DATABASE', DatabasePath('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => _env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'url' => _env('DATABASE_URL'),
'host' => _env('DB_HOST', '127.0.0.1'),
'port' => _env('DB_PORT', '3306'),
'database' => _env('DB_DATABASE', 'forge'),
'username' => _env('DB_USERNAME', 'forge'),
'password' => _env('DB_PASSWORD', ''),
'unix_socket' => _env('DB_SOCKET', ''),
'charset' => _env('DB_CHARSET', 'utf8mb4'),
'collation' => _env('DB_COLLATION', 'utf8mb4_unicode_ci'),
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => _env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => _env('DATABASE_URL'),
'host' => _env('DB_HOST', '127.0.0.1'),
'port' => _env('DB_PORT', '5432'),
'database' => _env('DB_DATABASE', 'forge'),
'username' => _env('DB_USERNAME', 'forge'),
'password' => _env('DB_PASSWORD', ''),
'charset' => _env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'url' => _env('DATABASE_URL'),
'host' => _env('DB_HOST', 'localhost'),
'port' => _env('DB_PORT', '1433'),
'database' => _env('DB_DATABASE', 'forge'),
'username' => _env('DB_USERNAME', 'forge'),
'password' => _env('DB_PASSWORD', ''),
'charset' => _env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
],
],
];
And this is the test:
<?php
declare(strict_types=1);
use App\DTO\Audiences\AudienceCreateDTO;
use App\Services\Audiences\CreateAudienceService;
require_once __DIR__ . '/../Support/DbHelpers.php';
it('creates an audience with stage filter and non-patients', function () {
ensureDbOrSkip();
truncateTables(['audiences','contacts','funnel_stages','users']);
// seed
seedUser(1);
$stages = seedFunnelStages(['compro']);
seedContacts([
[
'full_name' => 'Ana Perez',
'email' => '[email protected]',
'phone' => '+549111',
'source_channel' => 'web',
'funnel_stage' => ['current' => 'compro'],
'is_patient' => false,
'tags' => ['Ubicación: RM'],
],
[
'full_name' => 'Carlos Gomez',
'email' => '[email protected]',
'phone' => '+549222',
'source_channel' => 'web',
'funnel_stage' => ['current' => 'nuevo'],
'is_patient' => false,
'tags' => [],
],
[
'full_name' => 'Paciente X',
'email' => '[email protected]',
'phone' => '+549333',
'source_channel' => 'web',
'funnel_stage' => ['current' => 'compro'],
'is_patient' => true,
'tags' => ['Ubicación: RM'],
],
]);
$payload = [
'name' => 'No pacientes sin tags, stage compro',
'description' => 'No pacientes sin tags, stage compro',
'tags' => 'Edad: 18-35, Interés: Salud facial, Ubicación: RM',
'filters' => [
'stage' => 'compro',
'is_patient' => false,
],
'status' => 'active',
];
$dto = new AudienceCreateDTO($payload);
$resp = (new CreateAudienceService())($dto);
dd($resp);
expect($resp['status'] ?? null)->toBe('success');
$aud = $resp['content'];
expect($aud->name)->toBe('No pacientes sin tags, stage compro');
expect($aud->status)->toBe('active');
expect(is_array($aud->tags))->toBeTrue();
expect($aud->estimated_count)->toBeInt();
});
Can you help me?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels