Passed
Pull Request — master (#2)
by Alexander
01:11
created

ProxyTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 1
b 0
f 0
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSet() 0 9 1
A testCall() 0 9 1
A testGet() 0 9 1
1
<?php
2
3
4
namespace Yiisoft\Proxy\Tests;
5
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Proxy\Proxy;
9
10
final class ProxyTest extends TestCase
11
{
12
    public function testGet(): void
13
    {
14
        $handler = new ProxyHandler();
15
        $proxied = new Proxied();
16
        $proxy = new Proxy($proxied, $handler);
17
18
        $proxy->number1;
0 ignored issues
show
Bug Best Practice introduced by
The property number1 does not exist on Yiisoft\Proxy\Proxy. Since you implemented __get, consider adding a @property annotation.
Loading history...
19
20
        $this->assertEquals(['get', 'number1', $proxied], end($handler->calls));
21
    }
22
23
    public function testSet(): void
24
    {
25
        $handler = new ProxyHandler();
26
        $proxied = new Proxied();
27
        $proxy = new Proxy($proxied, $handler);
28
29
        $proxy->number1 = 1;
0 ignored issues
show
Bug Best Practice introduced by
The property number1 does not exist on Yiisoft\Proxy\Proxy. Since you implemented __set, consider adding a @property annotation.
Loading history...
30
31
        $this->assertEquals(['set', 'number1', 1, $proxied], end($handler->calls));
32
    }
33
34
    public function testCall(): void
35
    {
36
        $handler = new ProxyHandler();
37
        $proxied = new Proxied();
38
        $proxy = new Proxy($proxied, $handler);
39
40
        $proxy->setNumber1(1);
0 ignored issues
show
Bug introduced by
The method setNumber1() does not exist on Yiisoft\Proxy\Proxy. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

40
        $proxy->/** @scrutinizer ignore-call */ 
41
                setNumber1(1);
Loading history...
41
42
        $this->assertEquals(['call', 'setNumber1', [1], $proxied], end($handler->calls));
43
    }
44
}
45