-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1.12: Update LICENSE year Move test [phpspec-2-phpunit] First migrated tests (Model)
- Loading branch information
Showing
3 changed files
with
70 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Resource\Tests\Model; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\Argument; | ||
use Prophecy\PhpUnit\ProphecyTrait; | ||
use Sylius\Resource\Model\AbstractTranslation; | ||
use Sylius\Resource\Model\TranslatableInterface; | ||
use Sylius\Resource\Model\TranslationInterface; | ||
|
||
final class AbstractTranslationTest extends TestCase | ||
{ | ||
use ProphecyTrait; | ||
|
||
private AbstractTranslation $translation; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->translation = new ConcreteTranslation(); | ||
} | ||
|
||
public function testItIsATranslation(): void | ||
{ | ||
$this->assertInstanceOf(TranslationInterface::class, $this->translation); | ||
} | ||
|
||
public function testItsTranslatableIsMutable(): void | ||
{ | ||
$translatable = $this->prophesize(TranslatableInterface::class); | ||
|
||
$this->translation->setTranslatable($translatable->reveal()); | ||
$this->assertSame($translatable->reveal(), $this->translation->getTranslatable()); | ||
} | ||
|
||
public function testItsDetachesFromItsTranslatableCorrectly(): void | ||
{ | ||
$translatable1 = $this->prophesize(TranslatableInterface::class); | ||
$translatable2 = $this->prophesize(TranslatableInterface::class); | ||
|
||
$translatable1->addTranslation(Argument::type(AbstractTranslation::class))->shouldBeCalled(); | ||
$this->translation->setTranslatable($translatable1->reveal()); | ||
|
||
$translatable1->removeTranslation(Argument::type(AbstractTranslation::class))->shouldBeCalled(); | ||
$translatable2->addTranslation(Argument::type(AbstractTranslation::class))->shouldBeCalled(); | ||
$this->translation->setTranslatable($translatable2->reveal()); | ||
} | ||
|
||
public function testItsLocaleIsMutable(): void | ||
{ | ||
$this->translation->setLocale('en'); | ||
$this->assertSame('en', $this->translation->getLocale()); | ||
} | ||
} | ||
|
||
class ConcreteTranslation extends AbstractTranslation | ||
{ | ||
} |