NotFoundTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 28
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testException() 0 13 2
A testAfterRemove() 0 11 1
1
<?php
2
3
namespace Horat1us\MethodInjection\Tests;
4
5
use Horat1us\MethodInjection\DynamicObject;
6
use Horat1us\MethodInjection\MethodNotFoundException;
7
8
class NotFoundTest extends \PHPUnit_Framework_TestCase
9
{
10
    public function testException()
11
    {
12
        $object = new DynamicObject();
13
        $params = range(0, 100);
14
        shuffle($params);
15
        try {
16
            call_user_func([$object, 'undefinedMethod'], ...$params);
17
        } catch (MethodNotFoundException $ex) {
18
            $this->assertEquals($params, $ex->getArguments());
19
            $this->assertEquals($object, $ex->getObject());
20
            $this->assertEquals('undefinedMethod', $ex->getName());
21
        }
22
    }
23
24
    public function testAfterRemove()
25
    {
26
        $object = new DynamicObject();
27
        $object->{'method'} = function() {
28
            return true;
29
        };
30
        $this->assertTrue(call_user_func([$object, 'method']));
31
        $object->removeMethod('method');
32
        $this->expectException(MethodNotFoundException::class);
33
        $object->{'method'}();
34
    }
35
}
36
37