Codeception / Codeception/Codeception
Unit tests are failing when Postgres persistent connection is enabled
- Dominant language
- PHP
- Stars
- 4.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
#### What are you trying to achieve?
Unit test should pass when db persistent connection is enabled
#### What do you get instead?
Receiving error "[PDOException] There is already an active transaction"
```bash
[PDOException] There is already an active transaction
```
>
This is the database.php file db configuration in Laravel
'connections' => [
'cockroach' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'xxxxx'),
'port' => env('DB_PORT', 'xxxxx'),
'database' => env('DB_DATABASE', 'xxxxx'),
'username' => env('DB_USERNAME', 'xxxx'),
'sslmode' => 'require',
'sslkey' => env('DB_SSLKEY', "xxxx"),
'sslcert' => env('DB_SSLCERT', "xxxxx"),
'options' => array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_EMULATE_PREPARES => true,
PDO::ATTR_PERSISTENT => true),
],
]
Mocking database query builder to test functions written in Laravel repository classes (holds database logic)
```php
$this->builder = Mockery::mock('Illuminate\Database\Query\Builder');
$this->db = DB::shouldReceive('commit')->andReturnNull()
->shouldReceive('rollback')->andReturnNull()
->shouldReceive('beginTransaction')->andReturnNull()
->shouldReceive('getConnections')->andReturn([])
->shouldReceive('table')->andReturn($this->builder)
->shouldReceive('raw')->andReturn("");
```
### Details
* Codeception version: 4.1.17
* PHP Version: 7.4.4
* Operating System: Ubuntu
* Installation type: Composer
* List of installed packages (`composer show`)
* Suite configuration:
```yml
unit.suit.yml
actor: UnitTester
modules:
enabled:
- Asserts
- \Helper\Unit
- Laravel5
step_decorators: ~
```
Contributor guide
Assessment
This issue has not been assessed yet.