Mercurial > hg > isophonics-drupal-site
comparison vendor/phpunit/phpunit-mock-objects/tests/Invocation/StaticInvocationTest.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\TestCase; | |
12 use PHPUnit\Framework\MockObject\Invocation\StaticInvocation; | |
13 | |
14 class StaticInvocationTest extends TestCase | |
15 { | |
16 public function testConstructorRequiresClassAndMethodAndParameters() | |
17 { | |
18 $this->assertInstanceOf( | |
19 StaticInvocation::class, | |
20 new StaticInvocation( | |
21 'FooClass', | |
22 'FooMethod', | |
23 ['an_argument'], | |
24 'ReturnType' | |
25 ) | |
26 ); | |
27 } | |
28 | |
29 public function testAllowToGetClassNameSetInConstructor() | |
30 { | |
31 $invocation = new StaticInvocation( | |
32 'FooClass', | |
33 'FooMethod', | |
34 ['an_argument'], | |
35 'ReturnType' | |
36 ); | |
37 | |
38 $this->assertSame('FooClass', $invocation->getClassName()); | |
39 } | |
40 | |
41 public function testAllowToGetMethodNameSetInConstructor() | |
42 { | |
43 $invocation = new StaticInvocation( | |
44 'FooClass', | |
45 'FooMethod', | |
46 ['an_argument'], | |
47 'ReturnType' | |
48 ); | |
49 | |
50 $this->assertSame('FooMethod', $invocation->getMethodName()); | |
51 } | |
52 | |
53 public function testAllowToGetMethodParametersSetInConstructor() | |
54 { | |
55 $expectedParameters = [ | |
56 'foo', 5, ['a', 'b'], new stdClass, null, false | |
57 ]; | |
58 | |
59 $invocation = new StaticInvocation( | |
60 'FooClass', | |
61 'FooMethod', | |
62 $expectedParameters, | |
63 'ReturnType' | |
64 ); | |
65 | |
66 $this->assertSame($expectedParameters, $invocation->getParameters()); | |
67 } | |
68 | |
69 public function testConstructorAllowToSetFlagCloneObjectsInParameters() | |
70 { | |
71 $parameters = [new stdClass]; | |
72 $cloneObjects = true; | |
73 | |
74 $invocation = new StaticInvocation( | |
75 'FooClass', | |
76 'FooMethod', | |
77 $parameters, | |
78 'ReturnType', | |
79 $cloneObjects | |
80 ); | |
81 | |
82 $this->assertEquals($parameters, $invocation->getParameters()); | |
83 $this->assertNotSame($parameters, $invocation->getParameters()); | |
84 } | |
85 | |
86 public function testAllowToGetReturnTypeSetInConstructor() | |
87 { | |
88 $expectedReturnType = 'string'; | |
89 | |
90 $invocation = new StaticInvocation( | |
91 'FooClass', | |
92 'FooMethod', | |
93 ['an_argument'], | |
94 $expectedReturnType | |
95 ); | |
96 | |
97 $this->assertSame($expectedReturnType, $invocation->getReturnType()); | |
98 } | |
99 } |