NotFoundTest::testAfterRemove()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
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