|
11 | 11 |
|
12 | 12 | declare(strict_types=1); |
13 | 13 |
|
14 | | -namespace spec\Sylius\Resource\Model; |
| 14 | +namespace Sylius\Resource\Tests\Model; |
15 | 15 |
|
16 | | -use PhpSpec\ObjectBehavior; |
| 16 | +use PHPUnit\Framework\TestCase; |
17 | 17 | use Prophecy\Argument; |
| 18 | +use Prophecy\PhpUnit\ProphecyTrait; |
18 | 19 | use Sylius\Resource\Model\AbstractTranslation; |
19 | 20 | use Sylius\Resource\Model\TranslatableInterface; |
20 | 21 | use Sylius\Resource\Model\TranslationInterface; |
21 | 22 |
|
22 | | -final class AbstractTranslationSpec extends ObjectBehavior |
| 23 | +final class AbstractTranslationTest extends TestCase |
23 | 24 | { |
24 | | - function let(): void |
| 25 | + use ProphecyTrait; |
| 26 | + |
| 27 | + private AbstractTranslation $translation; |
| 28 | + |
| 29 | + protected function setUp(): void |
25 | 30 | { |
26 | | - $this->beAnInstanceOf('spec\Sylius\Resource\Model\ConcreteTranslation'); |
| 31 | + $this->translation = new ConcreteTranslation(); |
27 | 32 | } |
28 | 33 |
|
29 | | - function it_is_a_translation(): void |
| 34 | + public function testItIsATranslation(): void |
30 | 35 | { |
31 | | - $this->shouldImplement(TranslationInterface::class); |
| 36 | + $this->assertInstanceOf(TranslationInterface::class, $this->translation); |
32 | 37 | } |
33 | 38 |
|
34 | | - function its_translatable_is_mutable(TranslatableInterface $translatable): void |
| 39 | + public function testItsTranslatableIsMutable(): void |
35 | 40 | { |
36 | | - $this->setTranslatable($translatable); |
37 | | - $this->getTranslatable()->shouldReturn($translatable); |
| 41 | + $translatable = $this->prophesize(TranslatableInterface::class); |
| 42 | + |
| 43 | + $this->translation->setTranslatable($translatable->reveal()); |
| 44 | + $this->assertSame($translatable->reveal(), $this->translation->getTranslatable()); |
38 | 45 | } |
39 | 46 |
|
40 | | - function its_detaches_from_its_translatable_correctly( |
41 | | - TranslatableInterface $translatable1, |
42 | | - TranslatableInterface $translatable2, |
43 | | - ): void { |
44 | | - $translatable1->addTranslation(Argument::type(AbstractTranslation::class)); |
45 | | - $this->setTranslatable($translatable1); |
| 47 | + public function testItsDetachesFromItsTranslatableCorrectly(): void |
| 48 | + { |
| 49 | + $translatable1 = $this->prophesize(TranslatableInterface::class); |
| 50 | + $translatable2 = $this->prophesize(TranslatableInterface::class); |
| 51 | + |
| 52 | + $translatable1->addTranslation(Argument::type(AbstractTranslation::class))->shouldBeCalled(); |
| 53 | + $this->translation->setTranslatable($translatable1->reveal()); |
46 | 54 |
|
47 | | - $translatable1->removeTranslation(Argument::type(AbstractTranslation::class)); |
48 | | - $translatable2->addTranslation(Argument::type(AbstractTranslation::class)); |
49 | | - $this->setTranslatable($translatable2); |
| 55 | + $translatable1->removeTranslation(Argument::type(AbstractTranslation::class))->shouldBeCalled(); |
| 56 | + $translatable2->addTranslation(Argument::type(AbstractTranslation::class))->shouldBeCalled(); |
| 57 | + $this->translation->setTranslatable($translatable2->reveal()); |
50 | 58 | } |
51 | 59 |
|
52 | | - function its_locale_is_mutable(): void |
| 60 | + public function testItsLocaleIsMutable(): void |
53 | 61 | { |
54 | | - $this->setLocale('en'); |
55 | | - $this->getLocale()->shouldReturn('en'); |
| 62 | + $this->translation->setLocale('en'); |
| 63 | + $this->assertSame('en', $this->translation->getLocale()); |
56 | 64 | } |
57 | 65 | } |
58 | 66 |
|
|
0 commit comments