Passed
Push — master ( 9b7912...982aac )
by Janis
02:15
created

iCallMethodOnRepositoryWithExistingEntities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Janisbiz\LightOrm\Tests\Behat\Features\Dms\MySQL\Repository;
4
5
class RepositoryDeleteFeatureContext extends AbstractRepositoryFeatureContext
6
{
7
    /**
8
     * @When /^I call method "(.*)" on repository with existing entities$/
9
     *
10
     * @param string $method
11
     */
12
    public function iCallMethodOnRepositoryWithExistingEntities(string $method)
13
    {
14
        $this->callMethodOnRepositoryWithExistingEntities($method);
15
    }
16
17
    /**
18
     * @When /^I call method "(.*)" on repository with existing entities and expecting exception:$/
19
     *
20
     * @param string $method
21
     */
22
    public function iCallMethodOnRepositoryWithExistingEntitiesAndExpectingException(string $method)
23
    {
24
        try {
25
            $this->callMethodOnRepositoryWithExistingEntities($method);
26
        } catch (\Exception $e) {
27
            static::$exception = $e;
28
        }
29
    }
30
31
    /**
32
     * @param string $method
33
     */
34
    private function callMethodOnRepositoryWithExistingEntities(string $method)
35
    {
36
        foreach (static::$entities as $entity) {
37
            \call_user_func_array(
38
                [
39
                    static::$repository,
40
                    $method,
41
                ],
42
                [
43
                    'entity' => $entity,
44
                ]
45
            );
46
        }
47
    }
48
}
49