comparison vendor/phpunit/phpunit-mock-objects/tests/Invocation/ObjectInvocationTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php
2 /*
3 * This file is part of the phpunit-mock-objects package.
4 *
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 use PHPUnit\Framework\MockObject\Invocation\ObjectInvocation;
12 use PHPUnit\Framework\TestCase;
13
14 class ObjectInvocationTest extends TestCase
15 {
16 public function testConstructorRequiresClassAndMethodAndParametersAndObject()
17 {
18 $this->assertInstanceOf(
19 ObjectInvocation::class,
20 new ObjectInvocation(
21 'FooClass',
22 'FooMethod',
23 ['an_argument'],
24 'ReturnType',
25 new stdClass
26 )
27 );
28 }
29
30 public function testAllowToGetClassNameSetInConstructor()
31 {
32 $invocation = new ObjectInvocation(
33 'FooClass',
34 'FooMethod',
35 ['an_argument'],
36 'ReturnType',
37 new stdClass
38 );
39
40 $this->assertSame('FooClass', $invocation->getClassName());
41 }
42
43 public function testAllowToGetMethodNameSetInConstructor()
44 {
45 $invocation = new ObjectInvocation(
46 'FooClass',
47 'FooMethod',
48 ['an_argument'],
49 'ReturnType',
50 new stdClass
51 );
52
53 $this->assertSame('FooMethod', $invocation->getMethodName());
54 }
55
56 public function testAllowToGetObjectSetInConstructor()
57 {
58 $expectedObject = new stdClass;
59
60 $invocation = new ObjectInvocation(
61 'FooClass',
62 'FooMethod',
63 ['an_argument'],
64 'ReturnType',
65 $expectedObject
66 );
67
68 $this->assertSame($expectedObject, $invocation->getObject());
69 }
70
71 public function testAllowToGetMethodParametersSetInConstructor()
72 {
73 $expectedParameters = [
74 'foo', 5, ['a', 'b'], new stdClass, null, false
75 ];
76
77 $invocation = new ObjectInvocation(
78 'FooClass',
79 'FooMethod',
80 $expectedParameters,
81 'ReturnType',
82 new stdClass
83 );
84
85 $this->assertSame($expectedParameters, $invocation->getParameters());
86 }
87
88 public function testConstructorAllowToSetFlagCloneObjectsInParameters()
89 {
90 $parameters = [new stdClass];
91 $cloneObjects = true;
92
93 $invocation = new ObjectInvocation(
94 'FooClass',
95 'FooMethod',
96 $parameters,
97 'ReturnType',
98 new stdClass,
99 $cloneObjects
100 );
101
102 $this->assertEquals($parameters, $invocation->getParameters());
103 $this->assertNotSame($parameters, $invocation->getParameters());
104 }
105
106 public function testAllowToGetReturnTypeSetInConstructor()
107 {
108 $expectedReturnType = 'string';
109
110 $invocation = new ObjectInvocation(
111 'FooClass',
112 'FooMethod',
113 ['an_argument'],
114 $expectedReturnType,
115 new stdClass
116 );
117
118 $this->assertSame($expectedReturnType, $invocation->getReturnType());
119 }
120 }