1<?php
2class Framework_MockObject_Invocation_ObjectTest extends PHPUnit_Framework_TestCase
3{
4    public function testConstructorRequiresClassAndMethodAndParametersAndObject()
5    {
6        $this->assertInstanceOf(
7            PHPUnit_Framework_MockObject_Invocation_Object::class,
8            new PHPUnit_Framework_MockObject_Invocation_Object(
9                'FooClass',
10                'FooMethod',
11                ['an_argument'],
12                'ReturnType',
13                new stdClass
14            )
15        );
16    }
17
18    public function testAllowToGetClassNameSetInConstructor()
19    {
20        $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
21            'FooClass',
22            'FooMethod',
23            ['an_argument'],
24            'ReturnType',
25            new stdClass
26        );
27
28        $this->assertSame('FooClass', $invocation->className);
29    }
30
31    public function testAllowToGetMethodNameSetInConstructor()
32    {
33        $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
34            'FooClass',
35            'FooMethod',
36            ['an_argument'],
37            'ReturnType',
38            new stdClass
39        );
40
41        $this->assertSame('FooMethod', $invocation->methodName);
42    }
43
44    public function testAllowToGetObjectSetInConstructor()
45    {
46        $expectedObject = new stdClass;
47
48        $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
49            'FooClass',
50            'FooMethod',
51            ['an_argument'],
52            'ReturnType',
53            $expectedObject
54        );
55
56        $this->assertSame($expectedObject, $invocation->object);
57    }
58
59    public function testAllowToGetMethodParametersSetInConstructor()
60    {
61        $expectedParameters = [
62          'foo', 5, ['a', 'b'], new stdClass, null, false
63        ];
64
65        $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
66            'FooClass',
67            'FooMethod',
68            $expectedParameters,
69            'ReturnType',
70            new stdClass
71        );
72
73        $this->assertSame($expectedParameters, $invocation->parameters);
74    }
75
76    public function testConstructorAllowToSetFlagCloneObjectsInParameters()
77    {
78        $parameters   = [new stdClass];
79        $cloneObjects = true;
80
81        $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
82            'FooClass',
83            'FooMethod',
84            $parameters,
85            'ReturnType',
86            new stdClass,
87            $cloneObjects
88        );
89
90        $this->assertEquals($parameters, $invocation->parameters);
91        $this->assertNotSame($parameters, $invocation->parameters);
92    }
93
94    public function testAllowToGetReturnTypeSetInConstructor()
95    {
96        $expectedReturnType = 'string';
97
98        $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
99            'FooClass',
100            'FooMethod',
101            ['an_argument'],
102            $expectedReturnType,
103            new stdClass
104        );
105
106        $this->assertSame($expectedReturnType, $invocation->returnType);
107    }
108}
109