Completed
Push — master ( 591b88...b8acbf )
by Eric
07:01
created

LocaleResourceTest::testDefaultState()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 19
Ratio 100 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 19
loc 19
rs 9.4285
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Component\Locale\Tests\Resource;
13
14
use Lug\Component\Locale\Form\Type\Doctrine\MongoDB\LocaleChoiceType as DoctrineMongoDBLocaleChoiceType;
15
use Lug\Component\Locale\Form\Type\Doctrine\ORM\LocaleChoiceType as DoctrineORMLocaleChoiceType;
16
use Lug\Component\Locale\Form\Type\LocaleType;
17
use Lug\Component\Locale\Resource\LocaleResource;
18
use Lug\Component\Locale\Model\Locale;
19
use Lug\Component\Locale\Model\LocaleInterface;
20
use Lug\Component\Resource\Domain\DomainManager;
21
use Lug\Component\Resource\Factory\Factory;
22
use Lug\Component\Resource\Model\Resource;
23
use Lug\Component\Resource\Repository\Doctrine\MongoDB\Repository as DoctrineMongoDBRepository;
24
use Lug\Component\Resource\Repository\Doctrine\ORM\Repository as DoctrineORMRepository;
25
26
/**
27
 * @author GeLo <[email protected]>
28
 */
29
class LocaleResourceTest extends \PHPUnit_Framework_TestCase
30
{
31
    /**
32
     * @var LocaleResource
33
     */
34
    private $resource;
35
36
    /**
37
     * @var string
38
     */
39
    private $controller;
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    protected function setUp()
45
    {
46
        $this->controller = \stdClass::class;
47
        $this->resource = new LocaleResource($this->controller);
48
    }
49
50
    public function testInheritance()
51
    {
52
        $this->assertInstanceOf(Resource::class, $this->resource);
53
    }
54
55 View Code Duplication
    public function testDefaultState()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    {
57
        $this->assertSame('locale', $this->resource->getName());
58
        $this->assertSame(LocaleResource::DRIVER_DOCTRINE_ORM, $this->resource->getDriver());
59
        $this->assertSame('default', $this->resource->getDriverManager());
60
        $this->assertSame(realpath(__DIR__.'/../../Resources/Doctrine'), $this->resource->getDriverMappingPath());
61
        $this->assertSame(LocaleResource::DRIVER_MAPPING_FORMAT_XML, $this->resource->getDriverMappingFormat());
62
        $this->assertSame([LocaleInterface::class], $this->resource->getInterfaces());
63
        $this->assertSame(Locale::class, $this->resource->getModel());
64
        $this->assertSame(Factory::class, $this->resource->getFactory());
65
        $this->assertSame(DoctrineORMRepository::class, $this->resource->getRepository());
66
        $this->assertSame(LocaleType::class, $this->resource->getForm());
67
        $this->assertSame(DoctrineORMLocaleChoiceType::class, $this->resource->getChoiceForm());
68
        $this->assertSame($this->controller, $this->resource->getController());
69
        $this->assertSame(DomainManager::class, $this->resource->getDomainManager());
70
        $this->assertSame('code', $this->resource->getLabelPropertyPath());
71
        $this->assertSame('code', $this->resource->getIdPropertyPath());
72
        $this->assertNull($this->resource->getTranslation());
73
    }
74
75
    public function testMongoDBDriver()
76
    {
77
        $this->resource = new LocaleResource($this->controller, $driver = LocaleResource::DRIVER_DOCTRINE_MONGODB);
78
79
        $this->assertSame('locale', $this->resource->getName());
80
        $this->assertSame($driver, $this->resource->getDriver());
81
        $this->assertSame(realpath(__DIR__.'/../../Resources/Doctrine'), $this->resource->getDriverMappingPath());
82
        $this->assertSame(LocaleResource::DRIVER_MAPPING_FORMAT_XML, $this->resource->getDriverMappingFormat());
83
        $this->assertSame('default', $this->resource->getDriverManager());
84
        $this->assertSame([LocaleInterface::class], $this->resource->getInterfaces());
85
        $this->assertSame(Locale::class, $this->resource->getModel());
86
        $this->assertSame(Factory::class, $this->resource->getFactory());
87
        $this->assertSame(DoctrineMongoDBRepository::class, $this->resource->getRepository());
88
        $this->assertSame(LocaleType::class, $this->resource->getForm());
89
        $this->assertSame(DoctrineMongoDBLocaleChoiceType::class, $this->resource->getChoiceForm());
90
        $this->assertSame($this->controller, $this->resource->getController());
91
        $this->assertSame(DomainManager::class, $this->resource->getDomainManager());
92
        $this->assertSame('code', $this->resource->getLabelPropertyPath());
93
        $this->assertSame('code', $this->resource->getIdPropertyPath());
94
        $this->assertNull($this->resource->getTranslation());
95
    }
96
}
97