Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 class Framework_MockObject_Invocation_ObjectTest extends PHPUnit_Framework_TestCase
|
Chris@0
|
4 {
|
Chris@0
|
5 public function testConstructorRequiresClassAndMethodAndParametersAndObject()
|
Chris@0
|
6 {
|
Chris@0
|
7 new PHPUnit_Framework_MockObject_Invocation_Object(
|
Chris@0
|
8 'FooClass',
|
Chris@0
|
9 'FooMethod',
|
Chris@0
|
10 array('an_argument'),
|
Chris@0
|
11 new StdClass
|
Chris@0
|
12 );
|
Chris@0
|
13 }
|
Chris@0
|
14
|
Chris@0
|
15 public function testAllowToGetClassNameSetInConstructor()
|
Chris@0
|
16 {
|
Chris@0
|
17 $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
Chris@0
|
18 'FooClass',
|
Chris@0
|
19 'FooMethod',
|
Chris@0
|
20 array('an_argument'),
|
Chris@0
|
21 new StdClass
|
Chris@0
|
22 );
|
Chris@0
|
23
|
Chris@0
|
24 $this->assertSame('FooClass', $invocation->className);
|
Chris@0
|
25 }
|
Chris@0
|
26
|
Chris@0
|
27 public function testAllowToGetMethodNameSetInConstructor()
|
Chris@0
|
28 {
|
Chris@0
|
29 $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
Chris@0
|
30 'FooClass',
|
Chris@0
|
31 'FooMethod',
|
Chris@0
|
32 array('an_argument'),
|
Chris@0
|
33 new StdClass
|
Chris@0
|
34 );
|
Chris@0
|
35
|
Chris@0
|
36 $this->assertSame('FooMethod', $invocation->methodName);
|
Chris@0
|
37 }
|
Chris@0
|
38
|
Chris@0
|
39 public function testAllowToGetObjectSetInConstructor()
|
Chris@0
|
40 {
|
Chris@0
|
41 $expectedObject = new StdClass;
|
Chris@0
|
42
|
Chris@0
|
43 $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
Chris@0
|
44 'FooClass',
|
Chris@0
|
45 'FooMethod',
|
Chris@0
|
46 array('an_argument'),
|
Chris@0
|
47 $expectedObject
|
Chris@0
|
48 );
|
Chris@0
|
49
|
Chris@0
|
50 $this->assertSame($expectedObject, $invocation->object);
|
Chris@0
|
51 }
|
Chris@0
|
52
|
Chris@0
|
53 public function testAllowToGetMethodParametersSetInConstructor()
|
Chris@0
|
54 {
|
Chris@0
|
55 $expectedParameters = array(
|
Chris@0
|
56 'foo', 5, array('a', 'b'), new StdClass, null, false
|
Chris@0
|
57 );
|
Chris@0
|
58
|
Chris@0
|
59 $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
Chris@0
|
60 'FooClass',
|
Chris@0
|
61 'FooMethod',
|
Chris@0
|
62 $expectedParameters,
|
Chris@0
|
63 new StdClass
|
Chris@0
|
64 );
|
Chris@0
|
65
|
Chris@0
|
66 $this->assertSame($expectedParameters, $invocation->parameters);
|
Chris@0
|
67 }
|
Chris@0
|
68
|
Chris@0
|
69 public function testConstructorAllowToSetFlagCloneObjectsInParameters()
|
Chris@0
|
70 {
|
Chris@0
|
71 $parameters = array(new StdClass);
|
Chris@0
|
72 $cloneObjects = true;
|
Chris@0
|
73
|
Chris@0
|
74 $invocation = new PHPUnit_Framework_MockObject_Invocation_Object(
|
Chris@0
|
75 'FooClass',
|
Chris@0
|
76 'FooMethod',
|
Chris@0
|
77 $parameters,
|
Chris@0
|
78 new StdClass,
|
Chris@0
|
79 $cloneObjects
|
Chris@0
|
80 );
|
Chris@0
|
81
|
Chris@0
|
82 $this->assertEquals($parameters, $invocation->parameters);
|
Chris@0
|
83 $this->assertNotSame($parameters, $invocation->parameters);
|
Chris@0
|
84 }
|
Chris@0
|
85 }
|