Completed
Pull Request — 2.x (#124)
by Christian
02:30
created

ModelPersonalTranslatable::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
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\TranslationBundle\Tests\Traits;
13
14
use Sonata\TranslationBundle\Tests\Gedmo\ModelPersonalTranslatable;
15
use Sonata\TranslationBundle\Tests\Gedmo\ModelTranslatable;
16
use Sonata\TranslationBundle\Traits\Gedmo\PersonalTranslatableTrait;
17
use Sonata\TranslationBundle\Traits\TranslatableTrait;
18
19
/**
20
 * @author Nicolas Bastien <[email protected]>
21
 */
22 View Code Duplication
class GedmoTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
23
{
24
    /**
25
     * @test TranslatableTrait
26
     */
27
    public function testTranslatableModel()
28
    {
29
        $model = new ModelTranslatable();
30
        $model->setLocale('fr');
31
32
        $this->assertSame('fr', $model->getLocale());
33
        $this->assertTrue($model instanceof \Sonata\TranslationBundle\Model\TranslatableInterface);
34
    }
35
36
    /**
37
     * @test PersonalTranslatableTrait
38
     */
39
    public function testPersonalTranslatableModel()
40
    {
41
        $model = new ModelPersonalTranslatable();
42
        $model->setLocale('fr');
43
44
        $this->assertSame('fr', $model->getLocale());
45
        $this->assertTrue($model instanceof \Sonata\TranslationBundle\Model\TranslatableInterface);
46
47
        $model->addTranslation(new ModelPersonalTranslation('en', 'title', 'Title en'));
48
        $model->addTranslation(new ModelPersonalTranslation('it', 'title', 'Title it'));
49
        $model->addTranslation(new ModelPersonalTranslation('es', 'title', 'Title es'));
50
51
        $this->assertSame('Title en', $model->getTranslation('title', 'en'));
52
        $this->assertSame('Title it', $model->getTranslation('title', 'it'));
53
        $this->assertSame('Title es', $model->getTranslation('title', 'es'));
54
55
        $this->assertSame(3, count($model->getTranslations()));
56
    }
57
}
58