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

Commit 11fa1be

Browse filesBrowse files
minor symfony#50729 [CssSelector] Tests on Xpath translator will always pass (franckranaivo)
This PR was merged into the 5.4 branch. Discussion ---------- [CssSelector] Tests on Xpath translator will always pass While working on another PR (symfony#49388), I noticed that the assertion below will always pass as it is testing the count of the same array on both side. | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | | License | MIT | Doc PR | Instead of `$this->assertCount(\count($elementsId), $elementsId);` It should be `$this->assertCount(\count($elementsId), $elements);` This PR should fix also numbers and/or Xpath translator issues from this fixed assertion. P.S. This is the right PR for this issue (symfony#50726) Commits ------- bb123ab [CssSelector] Tests on Xpath translator will always pass
2 parents 5b05271 + bb123ab commit 11fa1be
Copy full SHA for 11fa1be

File tree

Expand file treeCollapse file tree

2 files changed

+11
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-7
lines changed

‎src/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,8 @@
4545
</div>
4646
<div id="foobar-div" foobar="ab bc
4747
cde"><span id="foobar-span"></span></div>
48-
</body></html>
48+
<section>
49+
<span id="no-siblings-of-any-type"></span>
50+
</section>
51+
</body>
52+
</html>

‎src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testHtmlIds($css, array $elementsId)
114114
$document->loadHTMLFile(__DIR__.'/Fixtures/ids.html');
115115
$document = simplexml_import_dom($document);
116116
$elements = $document->xpath($translator->cssToXPath($css));
117-
$this->assertCount(\count($elementsId), $elementsId);
117+
$this->assertCount(\count($elementsId), $elements);
118118
foreach ($elements as $element) {
119119
if (null !== $element->attributes()->id) {
120120
$this->assertContains((string) $element->attributes()->id, $elementsId);
@@ -302,14 +302,14 @@ public static function getHtmlIdsTestData()
302302
['li:nth-last-child(-n+1)', ['seventh-li']],
303303
['li:nth-last-child(-n+3)', ['fifth-li', 'sixth-li', 'seventh-li']],
304304
['ol:first-of-type', ['first-ol']],
305-
['ol:nth-child(1)', ['first-ol']],
305+
['ol:nth-child(4)', ['first-ol']],
306306
['ol:nth-of-type(2)', ['second-ol']],
307307
['ol:nth-last-of-type(1)', ['second-ol']],
308-
['span:only-child', ['foobar-span']],
308+
['span:only-child', ['foobar-span', 'no-siblings-of-any-type']],
309309
['li div:only-child', ['li-div']],
310310
['div *:only-child', ['li-div', 'foobar-span']],
311311
['p:only-of-type', ['paragraph']],
312-
[':only-of-type', ['html', 'li-div', 'foobar-span', 'paragraph']],
312+
[':only-of-type', ['html', 'li-div', 'foobar-span', 'no-siblings-of-any-type']],
313313
['div#foobar-div :only-of-type', ['foobar-span']],
314314
['a:empty', ['name-anchor']],
315315
['a:EMpty', ['name-anchor']],
@@ -318,8 +318,8 @@ public static function getHtmlIdsTestData()
318318
['html:root', ['html']],
319319
['li:root', []],
320320
['* :root', []],
321-
['*:contains("link")', ['html', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
322-
[':CONtains("link")', ['html', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
321+
['*:contains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
322+
[':CONtains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']],
323323
['*:contains("LInk")', []], // case sensitive
324324
['*:contains("e")', ['html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em']],
325325
['*:contains("E")', []], // case-sensitive

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.