Completed
Push — master ( f8f0da...220d87 )
by Razon
02:50
created

DbHelperTest::testTransaction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 3
1
<?php
2
namespace App\Tests\Unit\Helper;
3
4
use App\Helper\DbHelper;
5
use Codeception\Test\Unit;
6
7
class DbHelperTest extends Unit
8
{
9
    /**
10
     * @dataProvider dataTransaction
11
     */
12
    public function testTransaction(\Closure $callback, array $parameters, bool $success): void
13
    {
14
        if (!$success) {
15
            $this->expectException(\Throwable::class);
16
        }
17
        DbHelper::transaction($callback, $parameters);
18
    }
19
20
    public function dataTransaction(): array
21
    {
22
        return [
23
            [function() {}, [], true],
24
            [function() {
25
                throw new \Exception('fail');
26
            }, [], false],
27
        ];
28
    }
29
}
30