Completed
Push — master ( cf739f...382ea7 )
by
unknown
02:46
created

testIsTranslatableOnModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 14
loc 14
rs 9.4285
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\Checker;
13
14
use Sonata\TranslationBundle\Checker\TranslatableChecker;
15
use Sonata\TranslationBundle\Model\AbstractTranslatable;
16
use Sonata\TranslationBundle\Model\TranslatableInterface;
17
use Sonata\TranslationBundle\Traits\Translatable;
18
19
class ModelTranslatable extends AbstractTranslatable implements TranslatableInterface
20
{
21
}
22
23
class ModelCustomTranslatable
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 ModelUsingTraitTranslatable
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
    use Translatable;
30
}
31
32
/**
33
 * @author Nicolas Bastien <[email protected]>
34
 */
35
class TranslatableCheckerTest 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...
36
{
37
    /**
38
     * @test TranslatableChecker::isTranslatable
39
     */
40
    public function testIsTranslatableOnInterface()
41
    {
42
        $translatableChecker = new TranslatableChecker();
43
44
        $object = new ModelTranslatable();
45
46
        $this->assertFalse($translatableChecker->isTranslatable($object));
47
48
        $translatableChecker->setSupportedInterfaces(array(
49
            'Sonata\TranslationBundle\Model\TranslatableInterface',
50
        ));
51
52
        $this->assertTrue($translatableChecker->isTranslatable($object));
53
    }
54
55
    /**
56
     * @test TranslatableChecker::isTranslatable
57
     */
58
    public function testIsTranslatableOnModel()
59
    {
60
        $translatableChecker = new TranslatableChecker();
61
62
        $object = new ModelCustomTranslatable();
63
64
        $this->assertFalse($translatableChecker->isTranslatable($object));
65
66
        $translatableChecker->setSupportedModels(array(
67
            'Sonata\TranslationBundle\Tests\Checker\ModelCustomTranslatable',
68
        ));
69
70
        $this->assertTrue($translatableChecker->isTranslatable($object));
71
    }
72
73
    /**
74
     * @test TranslatableChecker::isTranslatable
75
     */
76
    public function testIsTranslatableOnTrait()
77
    {
78
        $translatableChecker = new TranslatableChecker();
79
80
        $object = new ModelUsingTraitTranslatable();
81
82
        $this->assertTrue($translatableChecker->isTranslatable($object));
83
    }
84
}
85