* @copyright 2022 Squiz Pty Ltd (ABN 77 084 670 600)
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
*/
namespace PHP_CodeSniffer\Tests\Core\Tokenizers\PHP;
use PHP_CodeSniffer\Tests\Core\Tokenizers\AbstractTokenizerTestCase;
final class HeredocStringTest extends AbstractTokenizerTestCase
{
/**
* Test that heredoc strings contain the complete interpolated string.
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param string $expectedContent The expected content of the heredoc string.
*
* @dataProvider dataHeredocString
* @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize
*
* @return void
*/
public function testHeredocString($testMarker, $expectedContent)
{
$tokens = $this->phpcsFile->getTokens();
$target = $this->getTargetToken($testMarker, T_HEREDOC);
$this->assertSame($expectedContent."\n", $tokens[$target]['content']);
}//end testHeredocString()
/**
* Test that heredoc strings contain the complete interpolated string when combined with other texts.
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param string $expectedContent The expected content of the heredoc string.
*
* @dataProvider dataHeredocString
* @covers PHP_CodeSniffer\Tokenizers\PHP::tokenize
*
* @return void
*/
public function testHeredocStringWrapped($testMarker, $expectedContent)
{
$tokens = $this->phpcsFile->getTokens();
$testMarker = substr($testMarker, 0, -3).'Wrapped */';
$target = $this->getTargetToken($testMarker, T_HEREDOC);
$this->assertSame('Do '.$expectedContent." Something\n", $tokens[$target]['content']);
}//end testHeredocStringWrapped()
/**
* Data provider.
*
* Type reference:
* 1. Directly embedded variables.
* 2. Braces outside the variable.
* 3. Braces after the dollar sign.
* 4. Variable variables and expressions.
*
* @link https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
*
* @see testHeredocString()
*
* @return array