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

AuthenticationServiceFactoryTest.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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);
47
    }
48
}
49