Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b06967e

Browse filesBrowse files
committed
minor #29798 Component CssSelector tests (vladis84)
This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #29798). Discussion ---------- Component CssSelector tests | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Write a short README entry for your feature/bugfix here (replace this comment block.) This will help people understand your PR and can be used as a start of the Doc PR. Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. --> Commits ------- c7410be Component CssSelector tests
2 parents ea68e28 + c7410be commit b06967e
Copy full SHA for b06967e

File tree

Expand file treeCollapse file tree

1 file changed

+60
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+60
-0
lines changed

‎src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php
+60Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
namespace Symfony\Component\CssSelector\Tests\XPath;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\CssSelector\Exception\ExpressionErrorException;
16+
use Symfony\Component\CssSelector\Node\ElementNode;
17+
use Symfony\Component\CssSelector\Node\FunctionNode;
18+
use Symfony\Component\CssSelector\Parser\Parser;
1519
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
1620
use Symfony\Component\CssSelector\XPath\Translator;
21+
use Symfony\Component\CssSelector\XPath\XPathExpr;
1722

1823
class TranslatorTest extends TestCase
1924
{
@@ -31,6 +36,61 @@ public function testCssToXPath($css, $xpath)
3136
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
3237
}
3338

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.