Completed
Push — master ( d17154...1fc820 )
by Sullivan
11:02 queued 08:59
created

GedmoTest::testPersonalTranslatableModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\AdminBundle\Tests\Model;
13
14
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslatable;
15
use Sonata\TranslationBundle\Model\Gedmo\AbstractPersonalTranslation;
16
use Sonata\TranslationBundle\Model\Gedmo\AbstractTranslatable;
17
use Sonata\TranslationBundle\Model\Gedmo\TranslatableInterface;
18
19
class ModelTranslatable extends AbstractTranslatable implements TranslatableInterface
20
{
21
}
22
23
class ModelPersonalTranslatable extends AbstractPersonalTranslatable implements TranslatableInterface
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
24
{
25
}
26
27
class ModelPersonalTranslation extends AbstractPersonalTranslation
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
28
{
29
}
30
31
/**
32
 * @author Nicolas Bastien <[email protected]>
33
 */
34
class GedmoTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
35
{
36
    /**
37
     * @test AbstractTranslatable
38
     */
39
    public function testTranslatableModel()
40
    {
41
        $model = new ModelTranslatable();
42
        $model->setLocale('fr');
43
44
        $this->assertSame('fr', $model->getLocale());
45
        $this->assertTrue($model instanceof \Sonata\TranslationBundle\Model\TranslatableInterface);
46
    }
47
48
    /**
49
     * @test AbstractPersonalTranslatable and AbstractPersonalTranslation
50
     */
51
    public function testPersonalTranslatableModel()
52
    {
53
        $model = new ModelPersonalTranslatable();
54
        $model->setLocale('fr');
55
56
        $this->assertSame('fr', $model->getLocale());
57
        $this->assertTrue($model instanceof \Sonata\TranslationBundle\Model\TranslatableInterface);
58
59
        $model->addTranslation(new ModelPersonalTranslation('en', 'title', 'Title en'));
60
        $model->addTranslation(new ModelPersonalTranslation('it', 'title', 'Title it'));
61
        $model->addTranslation(new ModelPersonalTranslation('es', 'title', 'Title es'));
62
63
        $this->assertSame('Title en', $model->getTranslation('title', 'en'));
64
        $this->assertSame('Title it', $model->getTranslation('title', 'it'));
65
        $this->assertSame('Title es', $model->getTranslation('title', 'es'));
66
67
        $this->assertSame(3, count($model->getTranslations()));
68
    }
69
}
70