33namespace Behat \Mink \Tests \Selector ;
44
55use Behat \Mink \Selector \NamedSelector ;
6- use Behat \Mink \Selector \SelectorsHandler ;
6+ use Behat \Mink \Selector \Xpath \ Escaper ;
77
88abstract class NamedSelectorTest extends \PHPUnit_Framework_TestCase
99{
@@ -42,10 +42,6 @@ public function testSelectors($fixtureFile, $selector, $locator, $expectedExactC
4242 $ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
4343 $ dom ->loadHTML (file_get_contents (__DIR__ .'/fixtures/ ' .$ fixtureFile ));
4444
45- // Escape the locator as Mink 1.x expects the caller of the NamedSelector to handle it
46- $ selectorsHandler = new SelectorsHandler ();
47- $ locator = $ selectorsHandler ->xpathLiteral ($ locator );
48-
4945 $ namedSelector = $ this ->getSelector ();
5046
5147 $ xpath = $ namedSelector ->translateToXPath (array ($ selector , $ locator ));
@@ -56,6 +52,20 @@ public function testSelectors($fixtureFile, $selector, $locator, $expectedExactC
5652 $ this ->assertEquals ($ expectedCount , $ nodeList ->length );
5753 }
5854
55+ /**
56+ * @dataProvider getSelectorTests
57+ */
58+ public function testEscapedSelectors ($ fixtureFile , $ selector , $ locator , $ expectedExactCount , $ expectedPartialCount = null )
59+ {
60+ // Escape the locator as Mink 1.x expects the caller of the NamedSelector to handle it
61+ $ escaper = new Escaper ();
62+ $ locator = $ escaper ->escapeLiteral ($ locator );
63+
64+ $ this ->iniSet ('error_reporting ' , -1 & ~E_USER_DEPRECATED );
65+
66+ $ this ->testSelectors ($ fixtureFile , $ selector , $ locator , $ expectedExactCount , $ expectedPartialCount );
67+ }
68+
5969 public function getSelectorTests ()
6070 {
6171 $ fieldCount = 8 ; // fields without `type` attribute
@@ -122,6 +132,7 @@ public function getSelectorTests()
122132
123133 // 3 matches, because matches every HTML node in path: html > body > div
124134 'content ' => array ('test.html ' , 'content ' , 'content-text ' , 1 , 4 ),
135+ 'content with quotes ' => array ('test.html ' , 'content ' , 'some "quoted" content ' , 1 , 3 ),
125136
126137 'select (name/label) ' => array ('test.html ' , 'select ' , 'the-field ' , 3 ),
127138 'select (with-id) ' => array ('test.html ' , 'select ' , 'the-field-select ' , 1 ),
0 commit comments