Skip to content

Commit 9233c4e

Browse files
committed
Merge branch '1.12' into 1.13
* 1.12: Update LICENSE year Move test [phpspec-2-phpunit] First migrated tests (Model)
2 parents b712809 + 7b64466 commit 9233c4e

File tree

3 files changed

+70
-62
lines changed

3 files changed

+70
-62
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2011-2023 (c) Sylius Sp. z o.o.
1+
Copyright (c) 2011-present Sylius Sp. z o.o.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

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)