Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 1ccc5be

Browse files
committed
Use self:: instead of $this-> for assert* methods
1 parent 6280454 commit 1ccc5be

11 files changed

+194
-194
lines changed

test/AbstractFactory/ReflectionBasedAbstractFactoryTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ public function nonClassRequestedNames()
3232
public function testCanCreateReturnsFalseForNonClassRequestedNames($requestedName)
3333
{
3434
$factory = new ReflectionBasedAbstractFactory();
35-
$this->assertFalse($factory->canCreate($this->container->reveal(), $requestedName));
35+
self::assertFalse($factory->canCreate($this->container->reveal(), $requestedName));
3636
}
3737

3838
public function testFactoryInstantiatesClassDirectlyIfItHasNoConstructor()
3939
{
4040
$factory = new ReflectionBasedAbstractFactory();
4141
$instance = $factory($this->container->reveal(), TestAsset\ClassWithNoConstructor::class);
42-
$this->assertInstanceOf(TestAsset\ClassWithNoConstructor::class, $instance);
42+
self::assertInstanceOf(TestAsset\ClassWithNoConstructor::class, $instance);
4343
}
4444

4545
public function testFactoryInstantiatesClassDirectlyIfConstructorHasNoArguments()
4646
{
4747
$factory = new ReflectionBasedAbstractFactory();
4848
$instance = $factory($this->container->reveal(), TestAsset\ClassWithEmptyConstructor::class);
49-
$this->assertInstanceOf(TestAsset\ClassWithEmptyConstructor::class, $instance);
49+
self::assertInstanceOf(TestAsset\ClassWithEmptyConstructor::class, $instance);
5050
}
5151

5252
public function testFactoryRaisesExceptionWhenUnableToResolveATypeHintedService()
@@ -82,8 +82,8 @@ public function testFactoryInjectsConfigServiceForConfigArgumentsTypeHintedAsArr
8282

8383
$factory = new ReflectionBasedAbstractFactory();
8484
$instance = $factory($this->container->reveal(), TestAsset\ClassAcceptingConfigToConstructor::class);
85-
$this->assertInstanceOf(TestAsset\ClassAcceptingConfigToConstructor::class, $instance);
86-
$this->assertEquals($config, $instance->config);
85+
self::assertInstanceOf(TestAsset\ClassAcceptingConfigToConstructor::class, $instance);
86+
self::assertEquals($config, $instance->config);
8787
}
8888

8989
public function testFactoryCanInjectKnownTypeHintedServices()
@@ -95,8 +95,8 @@ public function testFactoryCanInjectKnownTypeHintedServices()
9595

9696
$factory = new ReflectionBasedAbstractFactory();
9797
$instance = $factory($this->container->reveal(), TestAsset\ClassWithTypeHintedConstructorParameter::class);
98-
$this->assertInstanceOf(TestAsset\ClassWithTypeHintedConstructorParameter::class, $instance);
99-
$this->assertSame($sample, $instance->sample);
98+
self::assertInstanceOf(TestAsset\ClassWithTypeHintedConstructorParameter::class, $instance);
99+
self::assertSame($sample, $instance->sample);
100100
}
101101

102102
public function testFactoryResolvesTypeHintsForServicesToWellKnownServiceNames()
@@ -112,11 +112,11 @@ public function testFactoryResolvesTypeHintsForServicesToWellKnownServiceNames()
112112
$this->container->reveal(),
113113
TestAsset\ClassAcceptingWellKnownServicesAsConstructorParameters::class
114114
);
115-
$this->assertInstanceOf(
115+
self::assertInstanceOf(
116116
TestAsset\ClassAcceptingWellKnownServicesAsConstructorParameters::class,
117117
$instance
118118
);
119-
$this->assertSame($validators, $instance->validators);
119+
self::assertSame($validators, $instance->validators);
120120
}
121121

122122
public function testFactoryCanSupplyAMixOfParameterTypes()
@@ -135,12 +135,12 @@ public function testFactoryCanSupplyAMixOfParameterTypes()
135135

136136
$factory = new ReflectionBasedAbstractFactory([TestAsset\ValidatorPluginManager::class => 'ValidatorManager']);
137137
$instance = $factory($this->container->reveal(), TestAsset\ClassWithMixedConstructorParameters::class);
138-
$this->assertInstanceOf(TestAsset\ClassWithMixedConstructorParameters::class, $instance);
138+
self::assertInstanceOf(TestAsset\ClassWithMixedConstructorParameters::class, $instance);
139139

140-
$this->assertEquals($config, $instance->config);
141-
$this->assertEquals([], $instance->options);
142-
$this->assertSame($sample, $instance->sample);
143-
$this->assertSame($validators, $instance->validators);
140+
self::assertEquals($config, $instance->config);
141+
self::assertEquals([], $instance->options);
142+
self::assertSame($sample, $instance->sample);
143+
self::assertSame($validators, $instance->validators);
144144
}
145145

146146
public function testFactoryWillUseDefaultValueWhenPresentForScalarArgument()
@@ -151,7 +151,7 @@ public function testFactoryWillUseDefaultValueWhenPresentForScalarArgument()
151151
$this->container->reveal(),
152152
TestAsset\ClassWithScalarDependencyDefiningDefaultValue::class
153153
);
154-
$this->assertInstanceOf(TestAsset\ClassWithScalarDependencyDefiningDefaultValue::class, $instance);
155-
$this->assertEquals('bar', $instance->foo);
154+
self::assertInstanceOf(TestAsset\ClassWithScalarDependencyDefiningDefaultValue::class, $instance);
155+
self::assertEquals('bar', $instance->foo);
156156
}
157157
}

test/AbstractPluginManagerTest.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testInjectCreationContextInFactories()
5757

5858
$object = $pluginManager->get(InvokableObject::class);
5959

60-
$this->assertInstanceOf(InvokableObject::class, $object);
60+
self::assertInstanceOf(InvokableObject::class, $object);
6161
}
6262

6363
public function testValidateInstance()
@@ -95,9 +95,9 @@ public function testCachesInstanceByDefaultIfNoOptionsArePassed()
9595

9696
$first = $pluginManager->get(InvokableObject::class);
9797
$second = $pluginManager->get(InvokableObject::class);
98-
$this->assertInstanceOf(InvokableObject::class, $first);
99-
$this->assertInstanceOf(InvokableObject::class, $second);
100-
$this->assertSame($first, $second);
98+
self::assertInstanceOf(InvokableObject::class, $first);
99+
self::assertInstanceOf(InvokableObject::class, $second);
100+
self::assertSame($first, $second);
101101
}
102102

103103
public function shareByDefaultSettings()
@@ -127,9 +127,9 @@ public function testReturnsDiscreteInstancesIfOptionsAreProvidedRegardlessOfShar
127127

128128
$first = $pluginManager->get(InvokableObject::class, $options);
129129
$second = $pluginManager->get(InvokableObject::class, $options);
130-
$this->assertInstanceOf(InvokableObject::class, $first);
131-
$this->assertInstanceOf(InvokableObject::class, $second);
132-
$this->assertNotSame($first, $second);
130+
self::assertInstanceOf(InvokableObject::class, $first);
131+
self::assertInstanceOf(InvokableObject::class, $second);
132+
self::assertNotSame($first, $second);
133133
}
134134

135135
/**
@@ -164,13 +164,13 @@ function ($container, $name, $callback) {
164164
]);
165165

166166
$instance = $pluginManager->get(stdClass::class);
167-
$this->assertTrue(isset($instance->option), 'Delegator-injected option was not found');
168-
$this->assertEquals(
167+
self::assertTrue(isset($instance->option), 'Delegator-injected option was not found');
168+
self::assertEquals(
169169
$config['option'],
170170
$instance->option,
171171
'Delegator-injected option does not match configuration'
172172
);
173-
$this->assertEquals('bar', $instance->foo);
173+
self::assertEquals('bar', $instance->foo);
174174
}
175175

176176
/**
@@ -192,21 +192,21 @@ public function testGetRaisesExceptionWhenNoFactoryIsResolved()
192192
public function testCallingSetServiceLocatorSetsCreationContextWithDeprecationNotice()
193193
{
194194
set_error_handler(function ($errno, $errstr) {
195-
$this->assertEquals(E_USER_DEPRECATED, $errno);
195+
self::assertEquals(E_USER_DEPRECATED, $errno);
196196
}, E_USER_DEPRECATED);
197197
$pluginManager = new TestAsset\LenientPluginManager();
198198
restore_error_handler();
199199

200-
$this->assertAttributeSame($pluginManager, 'creationContext', $pluginManager);
200+
self::assertAttributeSame($pluginManager, 'creationContext', $pluginManager);
201201
$serviceManager = new ServiceManager();
202202

203203
set_error_handler(function ($errno, $errstr) {
204-
$this->assertEquals(E_USER_DEPRECATED, $errno);
204+
self::assertEquals(E_USER_DEPRECATED, $errno);
205205
}, E_USER_DEPRECATED);
206206
$pluginManager->setServiceLocator($serviceManager);
207207
restore_error_handler();
208208

209-
$this->assertAttributeSame($serviceManager, 'creationContext', $pluginManager);
209+
self::assertAttributeSame($serviceManager, 'creationContext', $pluginManager);
210210
}
211211

212212
/**
@@ -215,11 +215,11 @@ public function testCallingSetServiceLocatorSetsCreationContextWithDeprecationNo
215215
public function testPassingNoInitialConstructorArgumentSetsPluginManagerAsCreationContextWithDeprecationNotice()
216216
{
217217
set_error_handler(function ($errno, $errstr) {
218-
$this->assertEquals(E_USER_DEPRECATED, $errno);
218+
self::assertEquals(E_USER_DEPRECATED, $errno);
219219
}, E_USER_DEPRECATED);
220220
$pluginManager = new TestAsset\LenientPluginManager();
221221
restore_error_handler();
222-
$this->assertAttributeSame($pluginManager, 'creationContext', $pluginManager);
222+
self::assertAttributeSame($pluginManager, 'creationContext', $pluginManager);
223223
}
224224

225225
/**
@@ -231,12 +231,12 @@ public function testCanPassConfigInterfaceAsFirstConstructorArgumentWithDeprecat
231231
$config->toArray()->willReturn([]);
232232

233233
set_error_handler(function ($errno, $errstr) {
234-
$this->assertEquals(E_USER_DEPRECATED, $errno);
234+
self::assertEquals(E_USER_DEPRECATED, $errno);
235235
}, E_USER_DEPRECATED);
236236
$pluginManager = new TestAsset\LenientPluginManager($config->reveal());
237237
restore_error_handler();
238238

239-
$this->assertAttributeSame($pluginManager, 'creationContext', $pluginManager);
239+
self::assertAttributeSame($pluginManager, 'creationContext', $pluginManager);
240240
}
241241

242242
public function invalidConstructorArguments()
@@ -273,12 +273,12 @@ public function testPassingConfigInstanceAsFirstConstructorArgumentSkipsSecondAr
273273
$config->toArray()->willReturn(['services' => [__CLASS__ => $this]]);
274274

275275
set_error_handler(function ($errno, $errstr) {
276-
$this->assertEquals(E_USER_DEPRECATED, $errno);
276+
self::assertEquals(E_USER_DEPRECATED, $errno);
277277
}, E_USER_DEPRECATED);
278278
$pluginManager = new TestAsset\LenientPluginManager($config->reveal(), ['services' => [__CLASS__ => []]]);
279279
restore_error_handler();
280280

281-
$this->assertSame($this, $pluginManager->get(__CLASS__));
281+
self::assertSame($this, $pluginManager->get(__CLASS__));
282282
}
283283

284284
/**
@@ -288,7 +288,7 @@ public function testPassingConfigInstanceAsFirstConstructorArgumentSkipsSecondAr
288288
public function testAutoInvokableServicesAreNotKnownBeforeRetrieval()
289289
{
290290
$pluginManager = new TestAsset\SimplePluginManager(new ServiceManager());
291-
$this->assertFalse($pluginManager->has(TestAsset\InvokableObject::class));
291+
self::assertFalse($pluginManager->has(TestAsset\InvokableObject::class));
292292
}
293293

294294
/**
@@ -299,7 +299,7 @@ public function testSupportsRetrievingAutoInvokableServicesByDefault()
299299
{
300300
$pluginManager = new TestAsset\SimplePluginManager(new ServiceManager());
301301
$invokable = $pluginManager->get(TestAsset\InvokableObject::class);
302-
$this->assertInstanceOf(TestAsset\InvokableObject::class, $invokable);
302+
self::assertInstanceOf(TestAsset\InvokableObject::class, $invokable);
303303
}
304304

305305
/**
@@ -322,23 +322,23 @@ public function testValidateWillFallBackToValidatePluginWhenDefinedAndEmitDeprec
322322
$assertionCalled = false;
323323
$instance = (object) [];
324324
$assertion = function ($plugin) use ($instance, &$assertionCalled) {
325-
$this->assertSame($instance, $plugin);
325+
self::assertSame($instance, $plugin);
326326
$assertionCalled = true;
327327
};
328328
$pluginManager = new TestAsset\V2ValidationPluginManager(new ServiceManager());
329329
$pluginManager->assertion = $assertion;
330330

331331
$errorHandlerCalled = false;
332332
set_error_handler(function ($errno, $errmsg) use (&$errorHandlerCalled) {
333-
$this->assertEquals(E_USER_DEPRECATED, $errno);
334-
$this->assertContains('3.0', $errmsg);
333+
self::assertEquals(E_USER_DEPRECATED, $errno);
334+
self::assertContains('3.0', $errmsg);
335335
$errorHandlerCalled = true;
336336
}, E_USER_DEPRECATED);
337337
$pluginManager->validate($instance);
338338
restore_error_handler();
339339

340-
$this->assertTrue($assertionCalled, 'Assertion was not called by validatePlugin!');
341-
$this->assertTrue($errorHandlerCalled, 'Error handler was not triggered by validatePlugin!');
340+
self::assertTrue($assertionCalled, 'Assertion was not called by validatePlugin!');
341+
self::assertTrue($errorHandlerCalled, 'Error handler was not triggered by validatePlugin!');
342342
}
343343

344344
public function testSetServiceShouldRaiseExceptionForInvalidPlugin()
@@ -371,12 +371,12 @@ public function testAbstractFactoryGetsCreationContext()
371371
$abstractFactory->__invoke($serviceManager, 'foo', null)
372372
->willReturn(new InvokableObject());
373373
$pluginManager->addAbstractFactory($abstractFactory->reveal());
374-
$this->assertInstanceOf(InvokableObject::class, $pluginManager->get('foo'));
374+
self::assertInstanceOf(InvokableObject::class, $pluginManager->get('foo'));
375375
}
376376

377377
public function testAliasPropertyResolves()
378378
{
379379
$pluginManager = new V2v3PluginManager(new ServiceManager());
380-
$this->assertInstanceOf(InvokableObject::class, $pluginManager->get('foo'));
380+
self::assertInstanceOf(InvokableObject::class, $pluginManager->get('foo'));
381381
}
382382
}

0 commit comments

Comments
 (0)