Completed
Pull Request — master (#478)
by Gianluca
08:28 queued 05:42
created

testSetRepositoryFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace DoctrineORMModuleTest\Options;
21
22
use PHPUnit_Framework_TestCase as TestCase;
23
use DoctrineORMModule\Options\Configuration;
24
use Doctrine\ORM\Repository\DefaultRepositoryFactory;
25
26
class ConfigurationOptionsTest extends TestCase
27
{
28
    public function testSetGetNamingStrategy()
29
    {
30
        $options = new Configuration();
31
        $options->setNamingStrategy(null);
32
        $this->assertNull($options->getNamingStrategy());
33
34
        $options->setNamingStrategy('test');
35
        $this->assertSame('test', $options->getNamingStrategy());
36
37
        $namingStrategy = $this->getMock('Doctrine\ORM\Mapping\NamingStrategy');
38
        $options->setNamingStrategy($namingStrategy);
39
        $this->assertSame($namingStrategy, $options->getNamingStrategy());
40
41
        $this->setExpectedException('Zend\Stdlib\Exception\InvalidArgumentException');
42
        $options->setNamingStrategy(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|null|object<Doctr...Mapping\NamingStrategy>.

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 testSetGetQuoteStrategy()
46
    {
47
        $options = new Configuration();
48
        $options->setQuoteStrategy(null);
49
        $this->assertNull($options->getQuoteStrategy());
50
51
        $options->setQuoteStrategy('test');
52
        $this->assertSame('test', $options->getQuoteStrategy());
53
54
        $quoteStrategy = $this->getMock('Doctrine\ORM\Mapping\QuoteStrategy');
55
        $options->setQuoteStrategy($quoteStrategy);
56
        $this->assertSame($quoteStrategy, $options->getQuoteStrategy());
57
58
        $this->setExpectedException('Zend\Stdlib\Exception\InvalidArgumentException');
59
        $options->setQuoteStrategy(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|null|object<Doctr...\Mapping\QuoteStrategy>.

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 testSetRepositoryFactory()
63
    {
64
        $options = new Configuration();
65
        $options->setRepositoryFactory(null);
66
        $this->assertNull($options->getRepositoryFactory());
67
68
        $options->setRepositoryFactory('test');
69
        $this->assertSame('test', $options->getRepositoryFactory());
70
71
        $repositoryFactory = new DefaultRepositoryFactory();
72
        $options->setRepositoryFactory($repositoryFactory);
73
        $this->assertSame($repositoryFactory, $options->getRepositoryFactory());
74
75
        $this->setExpectedException('Zend\Stdlib\Exception\InvalidArgumentException');
76
        $options->setRepositoryFactory(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|null|object<Doctr...tory\RepositoryFactory>.

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...
77
    }
78
79
    public function testSetGetEntityListenerResolver()
80
    {
81
        $options = new Configuration();
82
83
        $options->setEntityListenerResolver(null);
84
        $this->assertNull($options->getEntityListenerResolver());
85
86
        $options->setEntityListenerResolver('test');
87
        $this->assertSame('test', $options->getEntityListenerResolver());
88
89
        $entityListenerResolver = $this->getMock('Doctrine\ORM\Mapping\EntityListenerResolver');
90
91
        $options->setEntityListenerResolver($entityListenerResolver);
92
        $this->assertSame($entityListenerResolver, $options->getEntityListenerResolver());
93
94
        $this->setExpectedException('Zend\Stdlib\Exception\InvalidArgumentException');
95
        $options->setEntityListenerResolver(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|null|object<Doctr...EntityListenerResolver>.

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...
96
    }
97
}
98