|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
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 spec\Sylius\Component\Resource\Model; |
|
13
|
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
|
15
|
|
|
use Prophecy\Argument; |
|
16
|
|
|
use Sylius\Component\Resource\Model\AbstractTranslation; |
|
17
|
|
|
use Sylius\Component\Resource\Model\TranslatableInterface; |
|
18
|
|
|
use Sylius\Component\Resource\Model\TranslationInterface; |
|
19
|
|
|
|
|
20
|
|
|
final class AbstractTranslationSpec extends ObjectBehavior |
|
21
|
|
|
{ |
|
22
|
|
|
function let() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->beAnInstanceOf('spec\Sylius\Component\Resource\Model\ConcreteTranslation'); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
function it_is_a_translation() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->shouldImplement(TranslationInterface::class); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
function its_translatable_is_mutable(TranslatableInterface $translatable) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->setTranslatable($translatable); |
|
35
|
|
|
$this->getTranslatable()->shouldReturn($translatable); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
function its_detaches_from_its_translatable_correctly( |
|
39
|
|
|
TranslatableInterface $translatable1, |
|
40
|
|
|
TranslatableInterface $translatable2 |
|
41
|
|
|
) { |
|
42
|
|
|
$translatable1->addTranslation(Argument::type(AbstractTranslation::class)); |
|
43
|
|
|
$this->setTranslatable($translatable1); |
|
44
|
|
|
|
|
45
|
|
|
$translatable1->removeTranslation(Argument::type(AbstractTranslation::class)); |
|
46
|
|
|
$translatable2->addTranslation(Argument::type(AbstractTranslation::class)); |
|
47
|
|
|
$this->setTranslatable($translatable2); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
function its_locale_is_mutable() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->setLocale('en'); |
|
53
|
|
|
$this->getLocale()->shouldReturn('en'); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
class ConcreteTranslation extends AbstractTranslation |
|
|
|
|
|
|
58
|
|
|
{ |
|
59
|
|
|
} |
|
60
|
|
|
|
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.