Skip to content

Commit ad7ae60

Browse files
committed
feat: use new event consts
1 parent 5872f41 commit ad7ae60

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

features/NodeProcessor/ArrayNodeProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ private function removeParent(array $nodes): array
3030

3131
public function getSubscribedEvents(string $nodePath, XmlProcessorContext $context): iterable
3232
{
33-
yield 'NodeType_' . \XMLReader::ELEMENT => [$this, 'openElement'];
34-
yield 'NodeType_' . \XMLReader::TEXT => [$this, 'textElement'];
33+
yield XmlProcessor::NODE_TYPE_ELEMENT => [$this, 'openElement'];
34+
yield XmlProcessor::NODE_TYPE_TEXT => [$this, 'textElement'];
3535
}
3636

3737
public function openElement(OpenContext $context): void

src/NodeProcessor/AbstractNodeProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public function getSubscribedEvents(string $nodePath, XmlProcessorContext $conte
2121
{
2222
if ($this->isNode($nodePath)) {
2323
if ($this instanceof OpenNodeProcessorInterface) {
24-
yield 'NodeType_' . \XMLReader::ELEMENT => [$this, 'openElement'];
24+
yield XmlProcessor::NODE_TYPE_ELEMENT => [$this, 'openElement'];
2525
}
2626
if ($this instanceof CloseNodeProcessorInterface) {
27-
yield 'NodeType_' . \XMLReader::END_ELEMENT => [$this, 'closeElement'];
27+
yield XmlProcessor::NODE_TYPE_END_ELEMENT => [$this, 'closeElement'];
2828
}
2929
if ($this instanceof TextNodeProcessorInterface) {
30-
yield 'NodeType_' . \XMLReader::TEXT => [$this, 'textElement'];
30+
yield XmlProcessor::NODE_TYPE_TEXT => [$this, 'textElement'];
3131
}
3232
}
3333
yield from [];

tests/Unit/Behat/NodeProcessor/ArrayNodeProcessorTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ function testGetSubscribedEvents(): void
2424
$context = $this->getMockBuilder(XmlProcessorContext::class)->disableOriginalConstructor()->getMock();
2525
self::assertIsIterable($nodeProcessor->getSubscribedEvents('test', $context));
2626
$events = iterator_to_array($nodeProcessor->getSubscribedEvents('test', $context));
27-
self::assertEquals([
28-
'NodeType_' . \XMLReader::ELEMENT => [$nodeProcessor, 'openElement'],
29-
'NodeType_' . \XMLReader::TEXT => [$nodeProcessor, 'textElement']
30-
], $events);
27+
self::assertEquals(
28+
[
29+
XmlProcessor::NODE_TYPE_ELEMENT => [$nodeProcessor, 'openElement'],
30+
XmlProcessor::NODE_TYPE_TEXT => [$nodeProcessor, 'textElement']
31+
],
32+
$events
33+
);
3134
}
3235

3336

0 commit comments

Comments
 (0)