Skip to content

Commit bb51d46

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: fix typo remove the WriteConfig class DX: PHP CS Fixer - keep Annotation,NamedArgumentConstructor,Target annotations as single group do not install FrameworkBundle 6.4 [Tests] Add `array` return type for provider methods [Tests] Move expectException closer to the place of the expectation to avoid false positives
2 parents b729ade + d036c6c commit bb51d46

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

Tests/CssSelectorConverterTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public function testParseExceptions()
4848
{
4949
$this->expectException(ParseException::class);
5050
$this->expectExceptionMessage('Expected identifier, but <eof at 3> found.');
51-
$converter = new CssSelectorConverter();
52-
$converter->toXPath('h1:');
51+
(new CssSelectorConverter())->toXPath('h1:');
5352
}
5453

5554
/** @dataProvider getCssToXPathWithoutPrefixTestData */
@@ -60,7 +59,7 @@ public function testCssToXPathWithoutPrefix($css, $xpath)
6059
$this->assertEquals($xpath, $converter->toXPath($css, ''), '->parse() parses an input string and returns a node');
6160
}
6261

63-
public static function getCssToXPathWithoutPrefixTestData()
62+
public static function getCssToXPathWithoutPrefixTestData(): array
6463
{
6564
return [
6665
['h1', 'h1'],

Tests/Parser/TokenStreamTest.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ public function testGetNextIdentifier()
5454

5555
public function testFailToGetNextIdentifier()
5656
{
57-
$this->expectException(SyntaxErrorException::class);
58-
5957
$stream = new TokenStream();
6058
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
59+
60+
$this->expectException(SyntaxErrorException::class);
61+
6162
$stream->getNextIdentifier();
6263
}
6364

@@ -74,10 +75,11 @@ public function testGetNextIdentifierOrStar()
7475

7576
public function testFailToGetNextIdentifierOrStar()
7677
{
77-
$this->expectException(SyntaxErrorException::class);
78-
7978
$stream = new TokenStream();
8079
$stream->push(new Token(Token::TYPE_DELIMITER, '.', 2));
80+
81+
$this->expectException(SyntaxErrorException::class);
82+
8183
$stream->getNextIdentifierOrStar();
8284
}
8385

Tests/XPath/TranslatorTest.php

+18-6
Original file line numberDiff line numberDiff line change
@@ -38,56 +38,68 @@ public function testCssToXPath($css, $xpath)
3838

3939
public function testCssToXPathPseudoElement()
4040
{
41-
$this->expectException(ExpressionErrorException::class);
4241
$translator = new Translator();
4342
$translator->registerExtension(new HtmlExtension($translator));
43+
44+
$this->expectException(ExpressionErrorException::class);
45+
4446
$translator->cssToXPath('e::first-line');
4547
}
4648

4749
public function testGetExtensionNotExistsExtension()
4850
{
49-
$this->expectException(ExpressionErrorException::class);
5051
$translator = new Translator();
5152
$translator->registerExtension(new HtmlExtension($translator));
53+
54+
$this->expectException(ExpressionErrorException::class);
55+
5256
$translator->getExtension('fake');
5357
}
5458

5559
public function testAddCombinationNotExistsExtension()
5660
{
57-
$this->expectException(ExpressionErrorException::class);
5861
$translator = new Translator();
5962
$translator->registerExtension(new HtmlExtension($translator));
6063
$parser = new Parser();
6164
$xpath = $parser->parse('*')[0];
6265
$combinedXpath = $parser->parse('*')[0];
66+
67+
$this->expectException(ExpressionErrorException::class);
68+
6369
$translator->addCombination('fake', $xpath, $combinedXpath);
6470
}
6571

6672
public function testAddFunctionNotExistsFunction()
6773
{
68-
$this->expectException(ExpressionErrorException::class);
6974
$translator = new Translator();
7075
$translator->registerExtension(new HtmlExtension($translator));
7176
$xpath = new XPathExpr();
7277
$function = new FunctionNode(new ElementNode(), 'fake');
78+
79+
$this->expectException(ExpressionErrorException::class);
80+
7381
$translator->addFunction($xpath, $function);
7482
}
7583

7684
public function testAddPseudoClassNotExistsClass()
7785
{
78-
$this->expectException(ExpressionErrorException::class);
7986
$translator = new Translator();
8087
$translator->registerExtension(new HtmlExtension($translator));
8188
$xpath = new XPathExpr();
89+
90+
$this->expectException(ExpressionErrorException::class);
91+
8292
$translator->addPseudoClass($xpath, 'fake');
8393
}
8494

8595
public function testAddAttributeMatchingClassNotExistsClass()
8696
{
87-
$this->expectException(ExpressionErrorException::class);
8897
$translator = new Translator();
8998
$translator->registerExtension(new HtmlExtension($translator));
9099
$xpath = new XPathExpr();
100+
101+
$this->expectException(ExpressionErrorException::class);
102+
91103
$translator->addAttributeMatching($xpath, '', '', '');
92104
}
93105

0 commit comments

Comments
 (0)