Definition at line 93 of file LightMockBuilderTest.php.
◆ setUp()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::setUp |
( |
| ) |
|
|
protected |
◆ testCallbackReceivesArguments()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCallbackReceivesArguments |
( |
| ) |
|
Definition at line 257 of file LightMockBuilderTest.php.
257 : void
258 {
259 $mock = $this->builder->create(LmbReturnTypesInterface::class);
260 $mock->__mockSetCallback(
'takesArgs', fn(
string $a,
int $b):
string =>
$a .
$b);
261 $this->assertSame('test7', $mock->takesArgs('test', 7));
262 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
References Vendor\Package\$a, and Vendor\Package\$b.
◆ testCallbackTakesPrecedenceOverConfiguredReturnValue()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCallbackTakesPrecedenceOverConfiguredReturnValue |
( |
| ) |
|
Definition at line 264 of file LightMockBuilderTest.php.
264 : void
265 {
266 $mock = $this->builder->create(LmbReturnTypesInterface::class);
267 $mock->__mockSetReturnValue('returnsString', 'from-value');
268 $mock->__mockSetCallback('returnsString', fn(): string => 'from-callback');
269 $this->assertSame('from-callback', $mock->returnsString());
270 }
◆ testCallingAStaticMethodOfAMockThrowsLogicException()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCallingAStaticMethodOfAMockThrowsLogicException |
( |
| ) |
|
Definition at line 135 of file LightMockBuilderTest.php.
135 : void
136 {
137 $mock = $this->builder->create(LmbStaticInterface::class);
138 $this->expectException(LogicException::class);
139 $mock::staticMethod();
140 }
◆ testCreateAbstractClassReturnsInstance()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCreateAbstractClassReturnsInstance |
( |
| ) |
|
Definition at line 110 of file LightMockBuilderTest.php.
110 : void
111 {
112 $mock = $this->builder->create(LmbAbstractBase::class);
113 $this->assertInstanceOf(LmbAbstractBase::class, $mock);
114 }
◆ testCreateAbstractClassWithAbstractStaticMethod()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCreateAbstractClassWithAbstractStaticMethod |
( |
| ) |
|
Definition at line 129 of file LightMockBuilderTest.php.
129 : void
130 {
131 $mock = $this->builder->create(LmbAbstractStaticBase::class);
132 $this->assertInstanceOf(LmbAbstractStaticBase::class, $mock);
133 }
◆ testCreateConcreteClassReturnsInstance()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCreateConcreteClassReturnsInstance |
( |
| ) |
|
Definition at line 116 of file LightMockBuilderTest.php.
116 : void
117 {
118 $mock = $this->builder->create(LmbConcreteClass::class);
119 $this->assertInstanceOf(LmbConcreteClass::class, $mock);
120 }
◆ testCreateEnumThrowsLogicException()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCreateEnumThrowsLogicException |
( |
| ) |
|
Definition at line 148 of file LightMockBuilderTest.php.
148 : void
149 {
150 $this->expectException(LogicException::class);
151 $this->builder->create(LmbTestEnum::class);
152 }
◆ testCreateFinalClassThrowsLogicException()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCreateFinalClassThrowsLogicException |
( |
| ) |
|
Definition at line 142 of file LightMockBuilderTest.php.
142 : void
143 {
144 $this->expectException(LogicException::class);
145 $this->builder->create(LmbFinalClass::class);
146 }
◆ testCreateInterfaceReturnsInstanceOfInterface()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCreateInterfaceReturnsInstanceOfInterface |
( |
| ) |
|
Definition at line 104 of file LightMockBuilderTest.php.
104 : void
105 {
106 $mock = $this->builder->create(LmbEmptyInterface::class);
107 $this->assertInstanceOf(LmbEmptyInterface::class, $mock);
108 }
◆ testCreateInterfaceWithStaticMethod()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCreateInterfaceWithStaticMethod |
( |
| ) |
|
Definition at line 122 of file LightMockBuilderTest.php.
122 : void
123 {
124 $mock = $this->builder->create(LmbStaticInterface::class);
125 $this->assertInstanceOf(LmbStaticInterface::class, $mock);
126 $this->assertSame('', $mock->instanceMethod());
127 }
◆ testCreateUnknownTypeThrowsLogicException()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testCreateUnknownTypeThrowsLogicException |
( |
| ) |
|
Definition at line 154 of file LightMockBuilderTest.php.
154 : void
155 {
156 $this->expectException(LogicException::class);
157 $this->builder->create('\\Non\\Existent\\TypeXyz');
158 }
◆ testDefaultArrayReturnsEmptyArray()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultArrayReturnsEmptyArray |
( |
| ) |
|
Definition at line 192 of file LightMockBuilderTest.php.
192 : void
193 {
194 $mock = $this->builder->create(LmbReturnTypesInterface::class);
195 $this->assertSame([], $mock->returnsArray());
196 }
◆ testDefaultBoolReturnsFalse()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultBoolReturnsFalse |
( |
| ) |
|
Definition at line 168 of file LightMockBuilderTest.php.
168 : void
169 {
170 $mock = $this->builder->create(LmbReturnTypesInterface::class);
171 $this->assertFalse($mock->returnsBool());
172 }
◆ testDefaultCallableReturnsCallable()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultCallableReturnsCallable |
( |
| ) |
|
Definition at line 216 of file LightMockBuilderTest.php.
216 : void
217 {
218 $mock = $this->builder->create(LmbReturnTypesInterface::class);
219 $this->assertIsCallable($mock->returnsCallable());
220 }
◆ testDefaultFloatReturnsZeroPointZero()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultFloatReturnsZeroPointZero |
( |
| ) |
|
Definition at line 180 of file LightMockBuilderTest.php.
180 : void
181 {
182 $mock = $this->builder->create(LmbReturnTypesInterface::class);
183 $this->assertEqualsWithDelta(0.0, $mock->returnsFloat(), PHP_FLOAT_EPSILON);
184 }
◆ testDefaultInterfaceReturnsMockImplementingThatInterface()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultInterfaceReturnsMockImplementingThatInterface |
( |
| ) |
|
Definition at line 222 of file LightMockBuilderTest.php.
222 : void
223 {
224 $mock = $this->builder->create(LmbReturnTypesInterface::class);
225 $this->assertInstanceOf(LmbReturnTypesInterface::class, $mock->returnsInterface());
226 }
◆ testDefaultIntReturnsZero()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultIntReturnsZero |
( |
| ) |
|
Definition at line 174 of file LightMockBuilderTest.php.
174 : void
175 {
176 $mock = $this->builder->create(LmbReturnTypesInterface::class);
177 $this->assertSame(0, $mock->returnsInt());
178 }
◆ testDefaultNullableStringReturnsNull()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultNullableStringReturnsNull |
( |
| ) |
|
Definition at line 198 of file LightMockBuilderTest.php.
198 : void
199 {
200 $mock = $this->builder->create(LmbReturnTypesInterface::class);
201 $this->assertNull($mock->returnsNullableString());
202 }
◆ testDefaultObjectReturnsStdClassInstance()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultObjectReturnsStdClassInstance |
( |
| ) |
|
Definition at line 204 of file LightMockBuilderTest.php.
204 : void
205 {
206 $mock = $this->builder->create(LmbReturnTypesInterface::class);
207 $this->assertInstanceOf(\stdClass::class, $mock->returnsObject());
208 }
◆ testDefaultSelfReturnsSameObject()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultSelfReturnsSameObject |
( |
| ) |
|
Definition at line 210 of file LightMockBuilderTest.php.
210 : void
211 {
212 $mock = $this->builder->create(LmbReturnTypesInterface::class);
213 $this->assertSame($mock, $mock->returnsSelf());
214 }
◆ testDefaultStringReturnsEmptyString()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultStringReturnsEmptyString |
( |
| ) |
|
Definition at line 186 of file LightMockBuilderTest.php.
186 : void
187 {
188 $mock = $this->builder->create(LmbReturnTypesInterface::class);
189 $this->assertSame('', $mock->returnsString());
190 }
◆ testDefaultValueForKnownMethodMatchesDirectInvocation()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultValueForKnownMethodMatchesDirectInvocation |
( |
| ) |
|
◆ testDefaultValueForUnknownMethodReturnsNull()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultValueForUnknownMethodReturnsNull |
( |
| ) |
|
◆ testDefaultVoidMethodReturnsNull()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDefaultVoidMethodReturnsNull |
( |
| ) |
|
Definition at line 162 of file LightMockBuilderTest.php.
162 : void
163 {
164 $mock = $this->builder->create(LmbReturnTypesInterface::class);
165 $this->assertNull($mock->returnsVoid());
166 }
◆ testDifferentTypesProduceDifferentClasses()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testDifferentTypesProduceDifferentClasses |
( |
| ) |
|
Definition at line 281 of file LightMockBuilderTest.php.
281 : void
282 {
283 $first = $this->builder->create(LmbEmptyInterface::class);
284 $second = $this->builder->create(LmbReturnTypesInterface::class);
285 $this->assertNotInstanceOf($first::class, $second);
286 }
◆ testNeverReturnMethodThrowsLogicException()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testNeverReturnMethodThrowsLogicException |
( |
| ) |
|
Definition at line 228 of file LightMockBuilderTest.php.
228 : void
229 {
230 $mock = $this->builder->create(LmbNeverInterface::class);
231 $this->expectException(LogicException::class);
232 $mock->neverReturns();
233 }
◆ testPHPUnitMockBuilderCreatesInterfaceMock()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testPHPUnitMockBuilderCreatesInterfaceMock |
( |
| ) |
|
Definition at line 290 of file LightMockBuilderTest.php.
290 : void
291 {
292 $mock = (new PHPUnitMockBuilder())->create(LmbReturnTypesInterface::class);
293
294 $this->assertInstanceOf(LmbReturnTypesInterface::class, $mock);
295 $this->assertSame(0, $mock->returnsInt());
296 }
◆ testSameTypeAlwaysProducesSameGeneratedClass()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testSameTypeAlwaysProducesSameGeneratedClass |
( |
| ) |
|
Definition at line 274 of file LightMockBuilderTest.php.
274 : void
275 {
276 $first = $this->builder->create(LmbEmptyInterface::class);
277 $second = $this->builder->create(LmbEmptyInterface::class);
278 $this->assertInstanceOf($first::class, $second);
279 }
◆ testSetCallbackOverridesDefault()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testSetCallbackOverridesDefault |
( |
| ) |
|
Definition at line 250 of file LightMockBuilderTest.php.
250 : void
251 {
252 $mock = $this->builder->create(LmbReturnTypesInterface::class);
253 $mock->__mockSetCallback('returnsString', fn(): string => 'hello');
254 $this->assertSame('hello', $mock->returnsString());
255 }
◆ testSetReturnValueFluentReturnsInstance()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testSetReturnValueFluentReturnsInstance |
( |
| ) |
|
Definition at line 244 of file LightMockBuilderTest.php.
244 : void
245 {
246 $mock = $this->builder->create(LmbReturnTypesInterface::class);
247 $this->assertSame($mock, $mock->__mockSetReturnValue('returnsInt', 1));
248 }
◆ testSetReturnValueOverridesDefault()
| ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::testSetReturnValueOverridesDefault |
( |
| ) |
|
Definition at line 237 of file LightMockBuilderTest.php.
237 : void
238 {
239 $mock = $this->builder->create(LmbReturnTypesInterface::class);
240 $mock->__mockSetReturnValue('returnsInt', 42);
241 $this->assertSame(42, $mock->returnsInt());
242 }
◆ $builder
| MockBuilder ILIAS\Component\Tests\Dependencies\LightMockBuilderTest::$builder |
|
private |
The documentation for this class was generated from the following file: