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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix compatibility with PHPUnit 4.8
  • Loading branch information
xabbuh committed Jan 14, 2019
commit 189da2252866407b798b6a0ca9a2d63d55b52946
25 changes: 18 additions & 7 deletions 25 src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\CssSelector\Tests\XPath;

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;
Expand All @@ -36,58 +35,70 @@ public function testCssToXPath($css, $xpath)
$this->assertEquals($xpath, $translator->cssToXPath($css, ''));
}

/**
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
*/
public function testCssToXPathPseudoElement()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$this->expectException(ExpressionErrorException::class);
$translator->cssToXPath('e::first-line');
}

/**
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
*/
public function testGetExtensionNotExistsExtension()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$this->expectException(ExpressionErrorException::class);
$translator->getExtension('fake');
}

/**
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
*/
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);
}

/**
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
*/
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);
}

/**
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
*/
public function testAddPseudoClassNotExistsClass()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$xpath = new XPathExpr();
$this->expectException(ExpressionErrorException::class);
$translator->addPseudoClass($xpath, 'fake');
}

/**
* @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
*/
public function testAddAttributeMatchingClassNotExistsClass()
{
$translator = new Translator();
$translator->registerExtension(new HtmlExtension($translator));
$xpath = new XPathExpr();
$this->expectException(ExpressionErrorException::class);
$translator->addAttributeMatching($xpath, '', '', '');
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.