Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commita747376

Browse files
Merge branch '6.4' into 7.2
* 6.4: fix compatibility with Relay 0.11 [Security] Handle non-callable implementations of `FirewallListenerInterface` [DomCrawler] Allow selecting `button`s by their `value` flip excluded properties with keys with Doctrine-style constraint config
2 parents19cc7b0 +22210aa commita747376

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

‎Crawler.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,12 +747,12 @@ public function selectImage(string $value): static
747747
}
748748

749749
/**
750-
* Selects a button byname or altvalue for images.
750+
* Selects a button byits text content, id,value, name or alt attribute.
751751
*/
752752
publicfunctionselectButton(string$value):static
753753
{
754754
return$this->filterRelativeXPath(
755-
\sprintf('descendant-or-self::input[((contains(%1$s, "submit") or contains(%1$s, "button")) and contains(concat(\'\', normalize-space(string(@value)),\'\'), %2$s)) or (contains(%1$s, "image") and contains(concat(\'\', normalize-space(string(@alt)),\'\'), %2$s)) or @id=%3$s or @name=%3$s] | descendant-or-self::button[contains(concat(\'\', normalize-space(string(.)),\'\'), %2$s) or @id=%3$s or @name=%3$s]','translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")',static::xpathLiteral(''.$value.''),static::xpathLiteral($value))
755+
\sprintf('descendant-or-self::input[((contains(%1$s, "submit") or contains(%1$s, "button")) and contains(concat(\'\', normalize-space(string(@value)),\'\'), %2$s)) or (contains(%1$s, "image") and contains(concat(\'\', normalize-space(string(@alt)),\'\'), %2$s)) or @id=%3$s or @name=%3$s] | descendant-or-self::button[contains(concat(\'\', normalize-space(string(.)),\'\'), %2$s) orcontains(concat(\'\', normalize-space(string(@value)),\'\'), %2$s) or@id=%3$s or @name=%3$s]','translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")',static::xpathLiteral(''.$value.''),static::xpathLiteral($value))
756756
);
757757
}
758758

‎Tests/AbstractCrawlerTestCase.php‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,10 @@ public function testFilterXpathComplexQueries()
452452
$this->assertCount(0,$crawler->filterXPath('/body'));
453453
$this->assertCount(1,$crawler->filterXPath('./body'));
454454
$this->assertCount(1,$crawler->filterXPath('.//body'));
455-
$this->assertCount(5,$crawler->filterXPath('.//input'));
455+
$this->assertCount(6,$crawler->filterXPath('.//input'));
456456
$this->assertCount(4,$crawler->filterXPath('//form')->filterXPath('//button | //input'));
457457
$this->assertCount(1,$crawler->filterXPath('body'));
458-
$this->assertCount(6,$crawler->filterXPath('//button | //input'));
458+
$this->assertCount(8,$crawler->filterXPath('//button | //input'));
459459
$this->assertCount(1,$crawler->filterXPath('//body'));
460460
$this->assertCount(1,$crawler->filterXPath('descendant-or-self::body'));
461461
$this->assertCount(1,$crawler->filterXPath('//div[@id="parent"]')->filterXPath('./div'),'A child selection finds only the current div');
@@ -723,16 +723,23 @@ public function testSelectButton()
723723
$this->assertNotSame($crawler,$crawler->selectButton('FooValue'),'->selectButton() returns a new instance of a crawler');
724724
$this->assertInstanceOf(Crawler::class,$crawler->selectButton('FooValue'),'->selectButton() returns a new instance of a crawler');
725725

726-
$this->assertEquals(1,$crawler->selectButton('FooValue')->count(),'->selectButton() selectsbuttons');
727-
$this->assertEquals(1,$crawler->selectButton('FooName')->count(),'->selectButton() selectsbuttons');
728-
$this->assertEquals(1,$crawler->selectButton('FooId')->count(),'->selectButton() selectsbuttons');
726+
$this->assertCount(1,$crawler->selectButton('FooValue'),'->selectButton() selectstype-submit inputs by value');
727+
$this->assertCount(1,$crawler->selectButton('FooName'),'->selectButton() selectstype-submit inputs by name');
728+
$this->assertCount(1,$crawler->selectButton('FooId'),'->selectButton() selectstype-submit inputs by id');
729729

730-
$this->assertEquals(1,$crawler->selectButton('BarValue')->count(),'->selectButton() selectsbuttons');
731-
$this->assertEquals(1,$crawler->selectButton('BarName')->count(),'->selectButton() selectsbuttons');
732-
$this->assertEquals(1,$crawler->selectButton('BarId')->count(),'->selectButton() selectsbuttons');
730+
$this->assertCount(1,$crawler->selectButton('BarValue'),'->selectButton() selectstype-button inputs by value');
731+
$this->assertCount(1,$crawler->selectButton('BarName'),'->selectButton() selectstype-button inputs by name');
732+
$this->assertCount(1,$crawler->selectButton('BarId'),'->selectButton() selectstype-button inputs by id');
733733

734-
$this->assertEquals(1,$crawler->selectButton('FooBarValue')->count(),'->selectButton() selects buttons with form attribute too');
735-
$this->assertEquals(1,$crawler->selectButton('FooBarName')->count(),'->selectButton() selects buttons with form attribute too');
734+
$this->assertCount(1,$crawler->selectButton('ImageAlt'),'->selectButton() selects type-image inputs by alt');
735+
736+
$this->assertCount(1,$crawler->selectButton('ButtonValue'),'->selectButton() selects buttons by value');
737+
$this->assertCount(1,$crawler->selectButton('ButtonName'),'->selectButton() selects buttons by name');
738+
$this->assertCount(1,$crawler->selectButton('ButtonId'),'->selectButton() selects buttons by id');
739+
$this->assertCount(1,$crawler->selectButton('ButtonText'),'->selectButton() selects buttons by text content');
740+
741+
$this->assertCount(1,$crawler->selectButton('FooBarValue'),'->selectButton() selects buttons with form attribute too');
742+
$this->assertCount(1,$crawler->selectButton('FooBarName'),'->selectButton() selects buttons with form attribute too');
736743
}
737744

738745
publicfunctiontestSelectButtonWithSingleQuotesInNameAttribute()
@@ -1322,6 +1329,9 @@ public function createTestCrawler($uri = null)
13221329
<input type="submit" value="FooBarValue" name="FooBarName" form="FooFormId" />
13231330
<input type="text" value="FooTextValue" name="FooTextName" form="FooFormId" />
13241331
1332+
<input type="image" alt="ImageAlt" form="FooFormId">
1333+
<button form="FooFormId">ButtonText</button>
1334+
13251335
<ul class="first">
13261336
<li class="first">One</li>
13271337
<li>Two</li>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp