Skip to content

Commit 49a9456

Browse files
authored
Merge pull request #936 from loic425/phpunit-2-phpspec/model
[phpspec-2-phpunit] migration of tests (Model)
2 parents 44d53e9 + 099125a commit 49a9456

File tree

2 files changed

+69
-61
lines changed

2 files changed

+69
-61
lines changed

src/Component/spec/Model/AbstractTranslationSpec.php

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Sylius package.
5+
*
6+
* (c) Sylius Sp. z o.o.
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+
declare(strict_types=1);
13+
14+
namespace Sylius\Resource\Tests\Model;
15+
16+
use PHPUnit\Framework\TestCase;
17+
use Prophecy\Argument;
18+
use Prophecy\PhpUnit\ProphecyTrait;
19+
use Sylius\Resource\Model\AbstractTranslation;
20+
use Sylius\Resource\Model\TranslatableInterface;
21+
use Sylius\Resource\Model\TranslationInterface;
22+
23+
final class AbstractTranslationTest extends TestCase
24+
{
25+
use ProphecyTrait;
26+
27+
private AbstractTranslation $translation;
28+
29+
protected function setUp(): void
30+
{
31+
$this->translation = new ConcreteTranslation();
32+
}
33+
34+
public function testItIsATranslation(): void
35+
{
36+
$this->assertInstanceOf(TranslationInterface::class, $this->translation);
37+
}
38+
39+
public function testItsTranslatableIsMutable(): void
40+
{
41+
$translatable = $this->prophesize(TranslatableInterface::class);
42+
43+
$this->translation->setTranslatable($translatable->reveal());
44+
$this->assertSame($translatable->reveal(), $this->translation->getTranslatable());
45+
}
46+
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());
54+
55+
$translatable1->removeTranslation(Argument::type(AbstractTranslation::class))->shouldBeCalled();
56+
$translatable2->addTranslation(Argument::type(AbstractTranslation::class))->shouldBeCalled();
57+
$this->translation->setTranslatable($translatable2->reveal());
58+
}
59+
60+
public function testItsLocaleIsMutable(): void
61+
{
62+
$this->translation->setLocale('en');
63+
$this->assertSame('en', $this->translation->getLocale());
64+
}
65+
}
66+
67+
class ConcreteTranslation extends AbstractTranslation
68+
{
69+
}

0 commit comments

Comments
 (0)