summaryrefslogtreecommitdiff
path: root/tests/test_php.py
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2016-06-03 11:49:39 -0700
committerTim Hatch <tim@timhatch.com>2016-06-03 11:49:39 -0700
commit45a929527133f272045acddaa78d783a0980f258 (patch)
treefd12de29deb8a5b4f3869b9f7e0592bf3e90abfd /tests/test_php.py
parent743bdf7725bd9d2dce43f9b1e36abc26dfbe0ecf (diff)
parent37b8969ae7e97911590660dd4f56ded096f63ad8 (diff)
downloadpygments-git-45a929527133f272045acddaa78d783a0980f258.tar.gz
Merged in pull request #595 (cmrx64/pygments-main)
Diffstat (limited to 'tests/test_php.py')
-rw-r--r--tests/test_php.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_php.py b/tests/test_php.py
new file mode 100644
index 00000000..050ca70d
--- /dev/null
+++ b/tests/test_php.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+"""
+ PHP Tests
+ ~~~~~~~~~
+
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import unittest
+
+from pygments.lexers import PhpLexer
+from pygments.token import Token
+
+
+class PhpTest(unittest.TestCase):
+ def setUp(self):
+ self.lexer = PhpLexer()
+
+ def testStringEscapingRun(self):
+ fragment = '<?php $x="{\\""; ?>\n'
+ tokens = [
+ (Token.Comment.Preproc, '<?php'),
+ (Token.Text, ' '),
+ (Token.Name.Variable, '$x'),
+ (Token.Operator, '='),
+ (Token.Literal.String.Double, '"'),
+ (Token.Literal.String.Double, '{'),
+ (Token.Literal.String.Escape, '\\"'),
+ (Token.Literal.String.Double, '"'),
+ (Token.Punctuation, ';'),
+ (Token.Text, ' '),
+ (Token.Comment.Preproc, '?>'),
+ (Token.Other, '\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))