12
12
namespace Symfony \Component \CssSelector \Tests \XPath ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
- use Symfony \Component \CssSelector \Exception \ExpressionErrorException ;
16
15
use Symfony \Component \CssSelector \Node \ElementNode ;
17
16
use Symfony \Component \CssSelector \Node \FunctionNode ;
18
17
use Symfony \Component \CssSelector \Parser \Parser ;
@@ -36,58 +35,70 @@ public function testCssToXPath($css, $xpath)
36
35
$ this ->assertEquals ($ xpath , $ translator ->cssToXPath ($ css , '' ));
37
36
}
38
37
38
+ /**
39
+ * @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
40
+ */
39
41
public function testCssToXPathPseudoElement ()
40
42
{
41
43
$ translator = new Translator ();
42
44
$ translator ->registerExtension (new HtmlExtension ($ translator ));
43
- $ this ->expectException (ExpressionErrorException::class);
44
45
$ translator ->cssToXPath ('e::first-line ' );
45
46
}
46
47
48
+ /**
49
+ * @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
50
+ */
47
51
public function testGetExtensionNotExistsExtension ()
48
52
{
49
53
$ translator = new Translator ();
50
54
$ translator ->registerExtension (new HtmlExtension ($ translator ));
51
- $ this ->expectException (ExpressionErrorException::class);
52
55
$ translator ->getExtension ('fake ' );
53
56
}
54
57
58
+ /**
59
+ * @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
60
+ */
55
61
public function testAddCombinationNotExistsExtension ()
56
62
{
57
63
$ translator = new Translator ();
58
64
$ translator ->registerExtension (new HtmlExtension ($ translator ));
59
- $ this ->expectException (ExpressionErrorException::class);
60
65
$ parser = new Parser ();
61
66
$ xpath = $ parser ->parse ('* ' )[0 ];
62
67
$ combinedXpath = $ parser ->parse ('* ' )[0 ];
63
68
$ translator ->addCombination ('fake ' , $ xpath , $ combinedXpath );
64
69
}
65
70
71
+ /**
72
+ * @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
73
+ */
66
74
public function testAddFunctionNotExistsFunction ()
67
75
{
68
76
$ translator = new Translator ();
69
77
$ translator ->registerExtension (new HtmlExtension ($ translator ));
70
78
$ xpath = new XPathExpr ();
71
79
$ function = new FunctionNode (new ElementNode (), 'fake ' );
72
- $ this ->expectException (ExpressionErrorException::class);
73
80
$ translator ->addFunction ($ xpath , $ function );
74
81
}
75
82
83
+ /**
84
+ * @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
85
+ */
76
86
public function testAddPseudoClassNotExistsClass ()
77
87
{
78
88
$ translator = new Translator ();
79
89
$ translator ->registerExtension (new HtmlExtension ($ translator ));
80
90
$ xpath = new XPathExpr ();
81
- $ this ->expectException (ExpressionErrorException::class);
82
91
$ translator ->addPseudoClass ($ xpath , 'fake ' );
83
92
}
84
93
94
+ /**
95
+ * @expectedException \Symfony\Component\CssSelector\Exception\ExpressionErrorException
96
+ */
85
97
public function testAddAttributeMatchingClassNotExistsClass ()
86
98
{
87
99
$ translator = new Translator ();
88
100
$ translator ->registerExtension (new HtmlExtension ($ translator ));
89
101
$ xpath = new XPathExpr ();
90
- $ this ->expectException (ExpressionErrorException::class);
91
102
$ translator ->addAttributeMatching ($ xpath , '' , '' , '' );
92
103
}
93
104
0 commit comments