Skip to content

Commit 3b97ad4

Browse files
committed
[phpspec-2-phpunit] First migrated tests (Model)
1 parent 44d53e9 commit 3b97ad4

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

src/Component/spec/Model/AbstractTranslationSpec.php

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,56 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace spec\Sylius\Resource\Model;
14+
namespace Sylius\Resource\Tests\Model;
1515

16-
use PhpSpec\ObjectBehavior;
16+
use PHPUnit\Framework\TestCase;
1717
use Prophecy\Argument;
18+
use Prophecy\PhpUnit\ProphecyTrait;
1819
use Sylius\Resource\Model\AbstractTranslation;
1920
use Sylius\Resource\Model\TranslatableInterface;
2021
use Sylius\Resource\Model\TranslationInterface;
2122

22-
final class AbstractTranslationSpec extends ObjectBehavior
23+
final class AbstractTranslationTest extends TestCase
2324
{
24-
function let(): void
25+
use ProphecyTrait;
26+
27+
private AbstractTranslation $translation;
28+
29+
protected function setUp(): void
2530
{
26-
$this->beAnInstanceOf('spec\Sylius\Resource\Model\ConcreteTranslation');
31+
$this->translation = new ConcreteTranslation();
2732
}
2833

29-
function it_is_a_translation(): void
34+
public function testItIsATranslation(): void
3035
{
31-
$this->shouldImplement(TranslationInterface::class);
36+
$this->assertInstanceOf(TranslationInterface::class, $this->translation);
3237
}
3338

34-
function its_translatable_is_mutable(TranslatableInterface $translatable): void
39+
public function testItsTranslatableIsMutable(): void
3540
{
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());
3845
}
3946

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());
4654

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());
5058
}
5159

52-
function its_locale_is_mutable(): void
60+
public function testItsLocaleIsMutable(): void
5361
{
54-
$this->setLocale('en');
55-
$this->getLocale()->shouldReturn('en');
62+
$this->translation->setLocale('en');
63+
$this->assertSame('en', $this->translation->getLocale());
5664
}
5765
}
5866

0 commit comments

Comments
 (0)