public function AfterParseBaseTest::testApplies in Feeds 8.3
Tests that if applies() returns false, no items are altered.
@covers ::afterParse
File
- tests/
src/ Unit/ EventSubscriber/ AfterParseBaseTest.php, line 137
Class
- AfterParseBaseTest
- @coversDefaultClass \Drupal\feeds\EventSubscriber\AfterParseBase @group feeds
Namespace
Drupal\Tests\feeds\Unit\EventSubscriberCode
public function testApplies() {
$subscriber = $this
->getMockBuilder(AfterParseBase::class)
->setMethods([
'applies',
'alterItem',
])
->getMock();
// Create a few items.
for ($i = 1; $i <= 3; $i++) {
$item = new DynamicItem();
$item
->set('id', $i);
$this->parserResult
->addItem($item);
}
$subscriber
->expects($this
->never())
->method('alterItem');
$subscriber
->expects($this
->once())
->method('applies')
->willReturn(FALSE);
// Run subscriber.
$subscriber
->afterParse($this->event);
}