mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 04:27:00 +00:00
Add more tests to the Lexer
This commit is contained in:
@@ -401,4 +401,32 @@ bar
|
||||
yield ['{{ ='];
|
||||
yield ['{{ ..'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTemplateForStrings
|
||||
*/
|
||||
public function testStrings(string $expected)
|
||||
{
|
||||
$template = '{{ "'.$expected.'" }}';
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
$stream = $lexer->tokenize(new Source($template, 'index'));
|
||||
$stream->expect(Token::VAR_START_TYPE);
|
||||
$stream->expect(Token::STRING_TYPE, $expected);
|
||||
|
||||
$template = "{{ '".$expected."' }}";
|
||||
$lexer = new Lexer(new Environment(new ArrayLoader()));
|
||||
$stream = $lexer->tokenize(new Source($template, 'index'));
|
||||
$stream->expect(Token::VAR_START_TYPE);
|
||||
$stream->expect(Token::STRING_TYPE, $expected);
|
||||
|
||||
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
||||
// can be executed without throwing any exceptions
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function getTemplateForStrings()
|
||||
{
|
||||
yield ["日本では、春になると桜の花が咲きます。多くの人々は、公園や川の近くに集まり、お花見を楽しみます。桜の花びらが風に舞い、まるで雪のように見える瞬間は、とても美しいです。"];
|
||||
yield ["في العالم العربي، يُعتبر الخط العربي أحد أجمل أشكال الفن. يُستخدم الخط في تزيين المساجد والكتب والمخطوطات القديمة. يتميز الخط العربي بجماله وتناسقه، ويُعتبر رمزًا للثقافة الإسلامية."];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user