testSetGetNamingStrategy()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace DoctrineORMModuleTest\Options;
4
5
use PHPUnit\Framework\TestCase;
6
use DoctrineORMModule\Options\Configuration;
7
use Doctrine\ORM\Repository\DefaultRepositoryFactory;
8
9
class ConfigurationOptionsTest extends TestCase
10
{
11
    public function testSetGetNamingStrategy()
12
    {
13
        $options = new Configuration();
14
        $options->setNamingStrategy(null);
15
        $this->assertNull($options->getNamingStrategy());
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
16
17
        $options->setNamingStrategy('test');
18
        $this->assertSame('test', $options->getNamingStrategy());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
19
20
        $namingStrategy = $this->createMock(\Doctrine\ORM\Mapping\NamingStrategy::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $namingStrategy is correct as $this->createMock(\Doctr...\NamingStrategy::class) (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
        $options->setNamingStrategy($namingStrategy);
22
        $this->assertSame($namingStrategy, $options->getNamingStrategy());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
23
24
        $this->expectException(\Laminas\Stdlib\Exception\InvalidArgumentException::class);
0 ignored issues
show
Bug introduced by
The method expectException() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
25
        $options->setNamingStrategy(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|object<Doctrine\O...ng\NamingStrategy>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
    }
27
28
    public function testSetGetQuoteStrategy()
29
    {
30
        $options = new Configuration();
31
        $options->setQuoteStrategy(null);
32
        $this->assertNull($options->getQuoteStrategy());
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
33
34
        $options->setQuoteStrategy('test');
35
        $this->assertSame('test', $options->getQuoteStrategy());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
36
37
        $quoteStrategy = $this->createMock(\Doctrine\ORM\Mapping\QuoteStrategy::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $quoteStrategy is correct as $this->createMock(\Doctr...g\QuoteStrategy::class) (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...
38
        $options->setQuoteStrategy($quoteStrategy);
39
        $this->assertSame($quoteStrategy, $options->getQuoteStrategy());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
40
41
        $this->expectException(\Laminas\Stdlib\Exception\InvalidArgumentException::class);
0 ignored issues
show
Bug introduced by
The method expectException() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
42
        $options->setQuoteStrategy(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|object<Doctrine\O...ing\QuoteStrategy>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
    }
44
45
    public function testSetRepositoryFactory()
46
    {
47
        $options = new Configuration();
48
        $options->setRepositoryFactory(null);
49
        $this->assertNull($options->getRepositoryFactory());
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
50
51
        $options->setRepositoryFactory('test');
52
        $this->assertSame('test', $options->getRepositoryFactory());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
53
54
        $repositoryFactory = new DefaultRepositoryFactory();
55
        $options->setRepositoryFactory($repositoryFactory);
56
        $this->assertSame($repositoryFactory, $options->getRepositoryFactory());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
57
58
        $this->expectException(\Laminas\Stdlib\Exception\InvalidArgumentException::class);
0 ignored issues
show
Bug introduced by
The method expectException() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
59
        $options->setRepositoryFactory(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|object<Doctrine\O...RepositoryFactory>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60
    }
61
62
    public function testSetGetEntityListenerResolver()
63
    {
64
        $options = new Configuration();
65
66
        $options->setEntityListenerResolver(null);
67
        $this->assertNull($options->getEntityListenerResolver());
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
68
69
        $options->setEntityListenerResolver('test');
70
        $this->assertSame('test', $options->getEntityListenerResolver());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
71
72
        $entityListenerResolver = $this->createMock(\Doctrine\ORM\Mapping\EntityListenerResolver::class);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $entityListenerResolver is correct as $this->createMock(\Doctr...istenerResolver::class) (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...
73
74
        $options->setEntityListenerResolver($entityListenerResolver);
75
        $this->assertSame($entityListenerResolver, $options->getEntityListenerResolver());
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
76
77
        $this->expectException(\Laminas\Stdlib\Exception\InvalidArgumentException::class);
0 ignored issues
show
Bug introduced by
The method expectException() does not seem to exist on object<DoctrineORMModule...nfigurationOptionsTest>.

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...
78
        $options->setEntityListenerResolver(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|object<Doctrine\O...yListenerResolver>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
79
    }
80
}
81