Completed
Push — master ( e0017c...6b1304 )
by Tom
14s queued 11s
created

testWillInstantiateFromFQCN()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 33

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 9.392
c 0
b 0
f 0
cc 1
nc 1
nop 0
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');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $objectManager is correct as $this->createMock('Doctr...stence\\ObjectManager') (which targets PHPUnit\Framework\TestCase::createMock()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

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.

Loading history...
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);
0 ignored issues
show
Bug introduced by
The method assertInstanceOf() does not seem to exist on object<DoctrineModuleTes...tionServiceFactoryTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
    }
48
}
49