Skip to content

Commit

Permalink
fix: Terminate segment terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
Apfelfrisch committed Feb 13, 2024
1 parent 5b8f206 commit 14a51a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Formatter/EdifactFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ private function escapeString(string $string): string
$this->unaSegment->escapeCharacter(),
$this->unaSegment->componentSeparator(),
$this->unaSegment->elementSeparator(),
$this->unaSegment->segmentTerminator(),
'\\n',
],
[
$this->unaSegment->escapeCharacter() . $this->unaSegment->escapeCharacter(),
$this->unaSegment->escapeCharacter() . $this->unaSegment->componentSeparator(),
$this->unaSegment->escapeCharacter() . $this->unaSegment->elementSeparator(),
$this->unaSegment->escapeCharacter() . $this->unaSegment->segmentTerminator(),
'',
],
$string
Expand Down
4 changes: 2 additions & 2 deletions tests/Formatter/EdifactFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function test_remove_loose_ends_string(): void
public function test_escaping_string(): void
{
$unaSegment = UnaSegment::getDefault();
$expectedString = "???:?+" . $unaSegment->segmentTerminator();
$expectedString = "???:?+?'" . $unaSegment->segmentTerminator();

$segment = AbstractSegmentTestSegment::fromAttributes('?:+');
$segment = AbstractSegmentTestSegment::fromAttributes("?:+'");

$this->assertSame($expectedString, (new EdifactFormatter($unaSegment))->format($segment));
}
Expand Down

0 comments on commit 14a51a7

Please sign in to comment.