Completed
Push — master ( af09d7...7599bb )
by Dorian
02:06
created

PhpUnitSimpleTestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSimpleMethods() 0 9 1
A setUpBeforeSimpleMethodsTests() 0 3 1
getSimpleMethodsData() 0 1 ?
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tests\Unit;
6
7
use PHPUnit\Framework\TestCase;
8
use Webmozart\Assert\Assert;
9
10
abstract class PhpUnitSimpleTestCase extends TestCase
11
{
12
    /** @var object */
13
    protected $instance;
14
15
    /**
16
     * @param mixed $expected
17
     *
18
     * @dataProvider getSimpleMethodsData
19
     */
20
    public function testSimpleMethods(string $method, array $arguments, $expected): void
21
    {
22
        Assert::object($this->instance);
23
24
        $this->setUpBeforeSimpleMethodsTests();
25
        $result = $this->instance->{$method}(...$arguments);
26
27
        $this->assertSame($expected, $result);
28
    }
29
30
    /**
31
     * Hook to be able to execute some code before the execution of the test
32
     */
33
    public function setUpBeforeSimpleMethodsTests(): void
34
    {
35
    }
36
37
    abstract public function getSimpleMethodsData(): array;
38
}
39