Completed
Push — master ( fdda4e...7c81d7 )
by ANTHONIUS
18s queued 12s
created

testMutableProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 10
rs 10
1
<?php
2
3
/*
4
 * This file is part of the EOffice project.
5
 *
6
 * (c) Anthonius Munthi <https://itstoni.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace EOffice\Testing\Concerns;
15
16
trait InteractsWithResourceProperties
17
{
18
    /**
19
     * @param string                  $propertyName
20
     * @param mixed|string|array|null $value
21
     * @dataProvider getPropertiesToTests
22
     */
23
    public function testMutableProperties(string $propertyName, $value): void
24
    {
25
        $class = $this->getResourceClassName();
26
        $ob    = new $class('test', 'test');
27
28
        $setter = 'set'.$propertyName;
29
        $getter = 'get'.$propertyName;
30
31
        \call_user_func([$ob, $setter], $value);
32
        $this->assertSame($value, \call_user_func([$ob, $getter]));
0 ignored issues
show
Bug introduced by
It seems like assertSame() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $this->/** @scrutinizer ignore-call */ 
33
               assertSame($value, \call_user_func([$ob, $getter]));
Loading history...
33
    }
34
35
    abstract public function getPropertiesToTests(): array;
36
37
    /**
38
     * @return string|class-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment string|class-string at position 2 could not be parsed: Unknown type name 'class-string' at position 2 in string|class-string.
Loading history...
39
     */
40
    abstract protected function getResourceClassName(): string;
41
}
42