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

Service/Authentication/AdapterFactoryTest.php (1 issue)

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 Laminas\ServiceManager\ServiceManager;
9
use PHPUnit\Framework\TestCase as BaseTestCase;
10
11
class AdapterFactoryTest extends BaseTestCase
12
{
13
    public function testWillInstantiateFromFQCN() : void
14
    {
15
        $name           = 'testFactory';
16
        $factory        = new AdapterFactory($name);
17
        $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...
18
        $serviceManager = new ServiceManager();
19
        $serviceManager->setService(
20
            'config',
21
            [
22
                'doctrine' => [
23
                    'authentication' => [
24
                        $name => [
25
                            'objectManager' => $objectManager,
26
                            'identityClass' => 'DoctrineModuleTest\Authentication\Adapter\TestAsset\IdentityObject',
27
                            'identityProperty' => 'username',
28
                            'credentialProperty' => 'password',
29
                        ],
30
                    ],
31
                ],
32
            ]
33
        );
34
35
        $adapter = $factory->createService($serviceManager);
36
        $this->assertInstanceOf('DoctrineModule\Authentication\Adapter\ObjectRepository', $adapter);
37
    }
38
}
39