-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\AutomatedTranslation\Encoder\Field; | ||
|
||
use Ibexa\AutomatedTranslation\Encoder\Field\TextBlockFieldEncoder; | ||
use Ibexa\Contracts\Core\Repository\Values\Content\Field; | ||
use Ibexa\Core\FieldType\TextBlock; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class TextBlockFieldEncoderTest extends TestCase | ||
{ | ||
private const TEXT_BLOCK_VALUE = "Some text.\nSome more text."; | ||
|
||
public function testEncode(): void | ||
{ | ||
$field = new Field([ | ||
'fieldDefIdentifier' => 'field_1_TextBlock', | ||
'value' => new TextBlock\Value(self::TEXT_BLOCK_VALUE), | ||
]); | ||
|
||
$subject = new TextBlockFieldEncoder(); | ||
$result = $subject->encode($field); | ||
|
||
$this->assertEquals(self::TEXT_BLOCK_VALUE, $result); | ||
} | ||
|
||
public function testDecode(): void | ||
{ | ||
$field = new Field([ | ||
'fieldDefIdentifier' => 'field_1_TextBlock', | ||
'value' => new TextBlock\Value(self::TEXT_BLOCK_VALUE), | ||
]); | ||
|
||
$subject = new TextBlockFieldEncoder(); | ||
$result = $subject->decode(self::TEXT_BLOCK_VALUE, $field->value); | ||
|
||
$this->assertInstanceOf(TextBlock\Value::class, $result); | ||
$this->assertEquals(new TextBlock\Value(self::TEXT_BLOCK_VALUE), $result); | ||
} | ||
} |