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\Bundle\ResourceBundle\Controller\Controller; |
15
|
|
|
use Lug\Bundle\ResourceBundle\Repository\Doctrine\MongoDB\Repository as DoctrineMongoDBRepository; |
16
|
|
|
use Lug\Bundle\ResourceBundle\Repository\Doctrine\ORM\Repository as DoctrineORMRepository; |
17
|
|
|
use Lug\Component\Locale\Form\Type\Doctrine\MongoDB\LocaleChoiceType as DoctrineMongoDBLocaleChoiceType; |
18
|
|
|
use Lug\Component\Locale\Form\Type\Doctrine\ORM\LocaleChoiceType as DoctrineORMLocaleChoiceType; |
19
|
|
|
use Lug\Component\Locale\Form\Type\LocaleType; |
20
|
|
|
use Lug\Component\Locale\Resource\LocaleResource; |
21
|
|
|
use Lug\Component\Locale\Model\Locale; |
22
|
|
|
use Lug\Component\Locale\Model\LocaleInterface; |
23
|
|
|
use Lug\Component\Resource\Domain\DomainManager; |
24
|
|
|
use Lug\Component\Resource\Factory\Factory; |
25
|
|
|
use Lug\Component\Resource\Model\Resource; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @author GeLo <[email protected]> |
29
|
|
|
*/ |
30
|
|
|
class LocaleResourceTest extends \PHPUnit_Framework_TestCase |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var LocaleResource |
34
|
|
|
*/ |
35
|
|
|
private $resource; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $bundlePath; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
|
|
protected function setUp() |
46
|
|
|
{ |
47
|
|
|
$this->bundlePath = realpath(__DIR__.'/../../'); |
48
|
|
|
$this->resource = new LocaleResource($this->bundlePath); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function testInheritance() |
52
|
|
|
{ |
53
|
|
|
$this->assertInstanceOf(Resource::class, $this->resource); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testDefaultState() |
57
|
|
|
{ |
58
|
|
|
$this->assertSame('locale', $this->resource->getName()); |
59
|
|
|
$this->assertSame(LocaleResource::DRIVER_DOCTRINE_ORM, $this->resource->getDriver()); |
60
|
|
|
$this->assertSame('default', $this->resource->getDriverManager()); |
61
|
|
|
$this->assertSame($this->bundlePath.'/Resources/config/resources', $this->resource->getDriverMappingPath()); |
62
|
|
|
$this->assertSame(LocaleResource::DRIVER_MAPPING_FORMAT_XML, $this->resource->getDriverMappingFormat()); |
63
|
|
|
$this->assertSame([LocaleInterface::class], $this->resource->getInterfaces()); |
64
|
|
|
$this->assertSame(Locale::class, $this->resource->getModel()); |
65
|
|
|
$this->assertSame(Factory::class, $this->resource->getFactory()); |
66
|
|
|
$this->assertSame(DoctrineORMRepository::class, $this->resource->getRepository()); |
67
|
|
|
$this->assertSame(LocaleType::class, $this->resource->getForm()); |
68
|
|
|
$this->assertSame(DoctrineORMLocaleChoiceType::class, $this->resource->getChoiceForm()); |
69
|
|
|
$this->assertSame(Controller::class, $this->resource->getController()); |
70
|
|
|
$this->assertSame(DomainManager::class, $this->resource->getDomainManager()); |
71
|
|
|
$this->assertSame('code', $this->resource->getLabelPropertyPath()); |
72
|
|
|
$this->assertSame('code', $this->resource->getIdPropertyPath()); |
73
|
|
|
$this->assertNull($this->resource->getTranslation()); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testMongoDBDriver() |
77
|
|
|
{ |
78
|
|
|
$this->resource = new LocaleResource($this->bundlePath, $driver = LocaleResource::DRIVER_DOCTRINE_MONGODB); |
79
|
|
|
|
80
|
|
|
$this->assertSame('locale', $this->resource->getName()); |
81
|
|
|
$this->assertSame($driver, $this->resource->getDriver()); |
82
|
|
|
$this->assertSame($this->bundlePath.'/Resources/config/resources', $this->resource->getDriverMappingPath()); |
83
|
|
|
$this->assertSame(LocaleResource::DRIVER_MAPPING_FORMAT_XML, $this->resource->getDriverMappingFormat()); |
84
|
|
|
$this->assertSame('default', $this->resource->getDriverManager()); |
85
|
|
|
$this->assertSame([LocaleInterface::class], $this->resource->getInterfaces()); |
86
|
|
|
$this->assertSame(Locale::class, $this->resource->getModel()); |
87
|
|
|
$this->assertSame(Factory::class, $this->resource->getFactory()); |
88
|
|
|
$this->assertSame(DoctrineMongoDBRepository::class, $this->resource->getRepository()); |
89
|
|
|
$this->assertSame(LocaleType::class, $this->resource->getForm()); |
90
|
|
|
$this->assertSame(DoctrineMongoDBLocaleChoiceType::class, $this->resource->getChoiceForm()); |
91
|
|
|
$this->assertSame(Controller::class, $this->resource->getController()); |
92
|
|
|
$this->assertSame(DomainManager::class, $this->resource->getDomainManager()); |
93
|
|
|
$this->assertSame('code', $this->resource->getLabelPropertyPath()); |
94
|
|
|
$this->assertSame('code', $this->resource->getIdPropertyPath()); |
95
|
|
|
$this->assertNull($this->resource->getTranslation()); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|