1# -*- coding: utf-8 -*-
2"""
3    PHP Tests
4    ~~~~~~~~~
5
6    :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
7    :license: BSD, see LICENSE for details.
8"""
9
10import pytest
11
12from pygments.lexers import PhpLexer
13from pygments.token import Token
14
15
16@pytest.fixture(scope='module')
17def lexer():
18    yield PhpLexer()
19
20
21def test_string_escaping_run(lexer):
22    fragment = '<?php $x="{\\""; ?>\n'
23    tokens = [
24        (Token.Comment.Preproc, '<?php'),
25        (Token.Text, ' '),
26        (Token.Name.Variable, '$x'),
27        (Token.Operator, '='),
28        (Token.Literal.String.Double, '"'),
29        (Token.Literal.String.Double, '{'),
30        (Token.Literal.String.Escape, '\\"'),
31        (Token.Literal.String.Double, '"'),
32        (Token.Punctuation, ';'),
33        (Token.Text, ' '),
34        (Token.Comment.Preproc, '?>'),
35        (Token.Other, '\n'),
36    ]
37    assert list(lexer.get_tokens(fragment)) == tokens
38