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
-------
c7410bef29
Component CssSelector tests
This commit is contained in:
commit
b06967e64f
@ -12,8 +12,13 @@
|
|||||||
namespace Symfony\Component\CssSelector\Tests\XPath;
|
namespace Symfony\Component\CssSelector\Tests\XPath;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\CssSelector\Exception\ExpressionErrorException;
|
||||||
|
use Symfony\Component\CssSelector\Node\ElementNode;
|
||||||
|
use Symfony\Component\CssSelector\Node\FunctionNode;
|
||||||
|
use Symfony\Component\CssSelector\Parser\Parser;
|
||||||
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
|
use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension;
|
||||||
use Symfony\Component\CssSelector\XPath\Translator;
|
use Symfony\Component\CssSelector\XPath\Translator;
|
||||||
|
use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||||
|
|
||||||
class TranslatorTest extends TestCase
|
class TranslatorTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -31,6 +36,61 @@ class TranslatorTest extends TestCase
|
|||||||
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
|
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCssToXPathPseudoElement()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$this->expectException(ExpressionErrorException::class);
|
||||||
|
$translator->cssToXPath('e::first-line');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetExtensionNotExistsExtension()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$this->expectException(ExpressionErrorException::class);
|
||||||
|
$translator->getExtension('fake');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddCombinationNotExistsExtension()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$this->expectException(ExpressionErrorException::class);
|
||||||
|
$parser = new Parser();
|
||||||
|
$xpath = $parser->parse('*')[0];
|
||||||
|
$combinedXpath = $parser->parse('*')[0];
|
||||||
|
$translator->addCombination('fake', $xpath, $combinedXpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddFunctionNotExistsFunction()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$xpath = new XPathExpr();
|
||||||
|
$function = new FunctionNode(new ElementNode(), 'fake');
|
||||||
|
$this->expectException(ExpressionErrorException::class);
|
||||||
|
$translator->addFunction($xpath, $function);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddPseudoClassNotExistsClass()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$xpath = new XPathExpr();
|
||||||
|
$this->expectException(ExpressionErrorException::class);
|
||||||
|
$translator->addPseudoClass($xpath, 'fake');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddAttributeMatchingClassNotExistsClass()
|
||||||
|
{
|
||||||
|
$translator = new Translator();
|
||||||
|
$translator->registerExtension(new HtmlExtension($translator));
|
||||||
|
$xpath = new XPathExpr();
|
||||||
|
$this->expectException(ExpressionErrorException::class);
|
||||||
|
$translator->addAttributeMatching($xpath, '', '', '');
|
||||||
|
}
|
||||||
|
|
||||||
/** @dataProvider getXmlLangTestData */
|
/** @dataProvider getXmlLangTestData */
|
||||||
public function testXmlLang($css, array $elementsId)
|
public function testXmlLang($css, array $elementsId)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user