diff --git a/src/EventSubscriber/FeedsSubscriber.php b/src/EventSubscriber/FeedsSubscriber.php index 2ef87fd..0eba2c2 100644 --- a/src/EventSubscriber/FeedsSubscriber.php +++ b/src/EventSubscriber/FeedsSubscriber.php @@ -5,7 +5,6 @@ namespace Drupal\feeds_tamper\EventSubscriber; use Drupal\feeds\Event\FeedsEvents; use Drupal\feeds\Event\ParseEvent; use Drupal\feeds_tamper\FeedTypeTamperManagerInterface; -use Exception; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -82,9 +81,7 @@ class FeedsSubscriber implements EventSubscriberInterface { // value needs to be iterated and each scalar separately transformed. if ($multiple && !$definition['handle_multiples']) { $new_value = []; - if (!is_array($item_value)) { - throw new Exception(sprintf('Tampering failed at %s plugin for source %s: %s received instead of an array.', $tamper->getSetting('uuid'), $source, $item_value)); - } + // @todo throw exception if $item_value is not an array. foreach ($item_value as $scalar_value) { $new_value[] = $tamper->tamper($scalar_value); } diff --git a/tests/src/Unit/EventSubscriber/FeedsSubscriberTest.php b/tests/src/Unit/EventSubscriber/FeedsSubscriberTest.php index ca6909e..1b98b65 100644 --- a/tests/src/Unit/EventSubscriber/FeedsSubscriberTest.php +++ b/tests/src/Unit/EventSubscriber/FeedsSubscriberTest.php @@ -11,7 +11,6 @@ use Drupal\feeds_tamper\FeedTypeTamperManagerInterface; use Drupal\feeds_tamper\FeedTypeTamperMetaInterface; use Drupal\tamper\TamperInterface; use Drupal\Tests\feeds_tamper\Unit\FeedsTamperTestCase; -use Exception; /** * @coversDefaultClass \Drupal\feeds_tamper\EventSubscriber\FeedsSubscriber @@ -189,34 +188,4 @@ class FeedsSubscriberTest extends FeedsTamperTestCase { $this->assertEquals(['FooFoo', 'FooFoo'], $item->get('alpha')); } - /** - * @covers ::afterParse - */ - public function testAfterParseException() { - $tamper = $this->prophesize(TamperInterface::class); - $tamper->tamper('Bar') - ->willReturn('tamper_return_string'); - $tamper->getPluginDefinition()->willReturn([ - 'handle_multiples' => FALSE, - ]); - $tamper->multiple()->willReturn(TRUE); - $tamper->getSetting('uuid') - ->willReturn('uuid1'); - $tamper = $tamper->reveal(); - - $this->tamperMeta->expects($this->once()) - ->method('getTampersGroupedBySource') - ->will($this->returnValue([ - 'alpha' => [$tamper, $tamper], - ])); - - // Add an item to the parser result. - $item = new DynamicItem(); - $item->set('alpha', 'Bar'); - $this->event->getParserResult()->addItem($item); - - $this->setExpectedException(Exception::class); - $this->subscriber->afterParse($this->event); - } - }