Skip to content

Commit be7ef80

Browse files
committed
Merge branch '4.1' into 4.2
* 4.1: bump required Twig version fix compatibility with Twig >= 2.6.1 [Form] SA fix fix compatibility with PHPUnit 4.8 remove return type hint for PHP 5 compatibility SCA: minor code tweaks Component CssSelector tests [DebugClassLoader] Readd findFile() method [Console] Fix composer.json suggest/provide Revert "bug #29597 [DI] fix reporting bindings on overriden services as unused (nicolas-grekas)" Fixed exception wording Fix SwiftMailerHandler to support Monolog's latest reset functionality
2 parents 76dac1d + d0d930c commit be7ef80

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

Tests/XPath/TranslatorTest.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
namespace Symfony\Component\CssSelector\Tests\XPath;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\CssSelector\Node\ElementNode;
16+
use Symfony\Component\CssSelector\Node\FunctionNode;
17+
use Symfony\Component\CssSelector\Parser\Parser;
1518
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
1619
use Symfony\Component\CssSelector\XPath\Translator;
20+
use Symfony\Component\CssSelector\XPath\XPathExpr;
1721

1822
class TranslatorTest extends TestCase
1923
{
@@ -31,6 +35,73 @@ public function testCssToXPath($css, $xpath)
3135
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
3236
}
3337

38+
/**
39+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
40+
*/
41+
public function testCssToXPathPseudoElement()
42+
{
43+
$translator = new Translator();
44+
$translator->registerExtension(new HtmlExtension($translator));
45+
$translator->cssToXPath('e::first-line');
46+
}
47+
48+
/**
49+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
50+
*/
51+
public function testGetExtensionNotExistsExtension()
52+
{
53+
$translator = new Translator();
54+
$translator->registerExtension(new HtmlExtension($translator));
55+
$translator->getExtension('fake');
56+
}
57+
58+
/**
59+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
60+
*/
61+
public function testAddCombinationNotExistsExtension()
62+
{
63+
$translator = new Translator();
64+
$translator->registerExtension(new HtmlExtension($translator));
65+
$parser = new Parser();
66+
$xpath = $parser->parse('*')[0];
67+
$combinedXpath = $parser->parse('*')[0];
68+
$translator->addCombination('fake', $xpath, $combinedXpath);
69+
}
70+
71+
/**
72+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
73+
*/
74+
public function testAddFunctionNotExistsFunction()
75+
{
76+
$translator = new Translator();
77+
$translator->registerExtension(new HtmlExtension($translator));
78+
$xpath = new XPathExpr();
79+
$function = new FunctionNode(new ElementNode(), 'fake');
80+
$translator->addFunction($xpath, $function);
81+
}
82+
83+
/**
84+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
85+
*/
86+
public function testAddPseudoClassNotExistsClass()
87+
{
88+
$translator = new Translator();
89+
$translator->registerExtension(new HtmlExtension($translator));
90+
$xpath = new XPathExpr();
91+
$translator->addPseudoClass($xpath, 'fake');
92+
}
93+
94+
/**
95+
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
96+
*/
97+
public function testAddAttributeMatchingClassNotExistsClass()
98+
{
99+
$translator = new Translator();
100+
$translator->registerExtension(new HtmlExtension($translator));
101+
$xpath = new XPathExpr();
102+
$translator->addAttributeMatching($xpath, '', '', '');
103+
}
104+
34105
/** @dataProvider getXmlLangTestData */
35106
public function testXmlLang($css, array $elementsId)
36107
{

0 commit comments

Comments
 (0)