Skip to content

Commit

Permalink
Merge pull request #936 from loic425/phpunit-2-phpspec/model
Browse files Browse the repository at this point in the history
[phpspec-2-phpunit] migration of tests (Model)
  • Loading branch information
lchrusciel authored Oct 22, 2024
2 parents 44d53e9 + 099125a commit 49a9456
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 61 deletions.
61 changes: 0 additions & 61 deletions src/Component/spec/Model/AbstractTranslationSpec.php

This file was deleted.

69 changes: 69 additions & 0 deletions src/Component/tests/Model/AbstractTranslationTest.php
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
{
}

0 comments on commit 49a9456

Please sign in to comment.