1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace DoctrineModuleTest\Service\Authentication; |
6
|
|
|
|
7
|
|
|
use DoctrineModule\Service\Authentication\AdapterFactory; |
8
|
|
|
use DoctrineModule\Service\Authentication\AuthenticationServiceFactory; |
9
|
|
|
use DoctrineModule\Service\Authentication\StorageFactory; |
10
|
|
|
use Laminas\ServiceManager\ServiceManager; |
11
|
|
|
use PHPUnit\Framework\TestCase as BaseTestCase; |
12
|
|
|
|
13
|
|
|
class AuthenticationServiceFactoryTest extends BaseTestCase |
14
|
|
|
{ |
15
|
|
|
public function testWillInstantiateFromFQCN() : void |
16
|
|
|
{ |
17
|
|
|
$name = 'testFactory'; |
18
|
|
|
$factory = new AuthenticationServiceFactory($name); |
19
|
|
|
|
20
|
|
|
$objectManager = $this->createMock('Doctrine\Persistence\ObjectManager'); |
|
|
|
|
21
|
|
|
|
22
|
|
|
$serviceManager = new ServiceManager(); |
23
|
|
|
$serviceManager->setService( |
24
|
|
|
'config', |
25
|
|
|
[ |
26
|
|
|
'doctrine' => [ |
27
|
|
|
'authentication' => [ |
28
|
|
|
$name => [ |
29
|
|
|
'objectManager' => $objectManager, |
30
|
|
|
'identityClass' => 'DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject', |
31
|
|
|
'identityProperty' => 'username', |
32
|
|
|
'credentialProperty' => 'password', |
33
|
|
|
], |
34
|
|
|
], |
35
|
|
|
], |
36
|
|
|
] |
37
|
|
|
); |
38
|
|
|
$serviceManager->setInvokableClass( |
39
|
|
|
'DoctrineModule\Authentication\Storage\Session', |
40
|
|
|
'Laminas\Authentication\Storage\Session' |
41
|
|
|
); |
42
|
|
|
$serviceManager->setFactory('doctrine.authenticationadapter.' . $name, new AdapterFactory($name)); |
43
|
|
|
$serviceManager->setFactory('doctrine.authenticationstorage.' . $name, new StorageFactory($name)); |
44
|
|
|
|
45
|
|
|
$authenticationService = $factory->createService($serviceManager); |
46
|
|
|
$this->assertInstanceOf('Laminas\Authentication\AuthenticationService', $authenticationService); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.