diff --git a/src/Language/Printer.php b/src/Language/Printer.php index 3c9873f..69a3ca9 100644 --- a/src/Language/Printer.php +++ b/src/Language/Printer.php @@ -488,6 +488,6 @@ class Printer return (($value[0] === ' ' || $value[0] === "\t") && strpos($value, "\n") === false) ? ('"""' . preg_replace('/"$/', "\"\n", $escaped) . '"""') - : ("\"\"\"\n" . ($isDescription ? $escaped : $this->indent($escaped)) . "\n\"\"\""); + : ('"""' . "\n" . ($isDescription ? $escaped : $this->indent($escaped)) . "\n" . '"""'); } } diff --git a/tests/Language/PrinterTest.php b/tests/Language/PrinterTest.php index 0df809c..3926ea2 100644 --- a/tests/Language/PrinterTest.php +++ b/tests/Language/PrinterTest.php @@ -95,7 +95,7 @@ class PrinterTest extends TestCase } /** - * @it correctly prints single-line block strings with leading space + * @it correctly prints single-line with leading space */ public function testCorrectlyPrintsSingleLineBlockStringsWithLeadingSpace() { @@ -110,7 +110,7 @@ class PrinterTest extends TestCase } /** - * @it correctly prints block strings with a first line indentation + * @it correctly prints string with a first line indentation */ public function testCorrectlyPrintsBlockStringsWithAFirstLineIndentation() { @@ -134,6 +134,27 @@ class PrinterTest extends TestCase $this->assertEquals($expected, Printer::doPrint($mutationAstWithArtifacts)); } + /** + * @it correctly prints single-line with leading space and quotation + */ + public function testCorrectlyPrintsSingleLineWithLeadingSpaceAndQuotation() + { + $mutationAstWithArtifacts = Parser::parse(' + { + field(arg: """ space-led value "quoted string" + """) + } + '); + $expected = <<assertEquals($expected, Printer::doPrint($mutationAstWithArtifacts)); + } + /** * @it Experimental: correctly prints fragment defined variables */