Skip to content

Commit

Permalink
Merge branch '1.12' into 1.13
Browse files Browse the repository at this point in the history
* 1.12:
  Update LICENSE year
  Move test
  [phpspec-2-phpunit] First migrated tests (Model)
  • Loading branch information
GSadee committed Nov 29, 2024
2 parents b712809 + 7b64466 commit 9233c4e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 62 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011-2023 (c) Sylius Sp. z o.o.
Copyright (c) 2011-present Sylius Sp. z o.o.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
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 9233c4e

Please sign in to comment.