Skip to content

Commit

Permalink
add parse raw value string test
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 9, 2022
1 parent 36c5a77 commit b3649e5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/PhpParser/Node/Scalar/StringTest.php
Expand Up @@ -2,8 +2,28 @@

namespace PhpParser\Node\Scalar;

use PhpParser\Node\Stmt\Echo_;
use PhpParser\ParserFactory;

class StringTest extends \PHPUnit\Framework\TestCase
{
public function testRawValue()
{
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
$nodes = $parser->parse('<?php echo "sequence \x41";');

$echo = $nodes[0];
$this->assertInstanceOf(Echo_::class, $echo);

/** @var Echo_ $echo */
$string = $echo->exprs[0];
$this->assertInstanceOf(String_::class, $string);

/** @var String_ $string */
$this->assertSame('sequence A', $string->value);
$this->assertSame('"sequence \\x41"', $string->rawValue);
}

/**
* @dataProvider provideTestParseEscapeSequences
*/
Expand Down

0 comments on commit b3649e5

Please sign in to comment.