Skip to content

Commit 2974831

Browse files
committed
Fixed stepExecution injection into readers
1 parent 0bb6d23 commit 2974831

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

Entity/StepExecution.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,18 @@ function ($e) {
488488
);
489489
}
490490

491+
public function addError($message)
492+
{
493+
$this->errors[] = $message;
494+
495+
return $this;
496+
}
497+
498+
public function getErrors()
499+
{
500+
return $this->errors;
501+
}
502+
491503
/**
492504
* To string
493505
* @return string

Item/Support/ArrayReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function setItems(array $items)
2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function read(StepExecution $stepExecution)
32+
public function read()
3333
{
3434
$item = null;
3535

Tests/Unit/EventListener/LoggerSubscriberTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,8 @@ public function testInvalidReaderExecution()
178178
->expects($this->once())
179179
->method('warning')
180180
->with(
181-
$this->matchesRegularExpression(
182-
'/^The .+ was unable to handle the following data: \[foo => bar\] '.
183-
'\(REASON: This is a valid reason\.\)\.$/'
184-
)
181+
'The Oro\Bundle\BatchBundle\Item\ItemReaderInterface was unable ' .
182+
'to handle the following data: [foo => bar] (REASON: This is a valid reason.).'
185183
);
186184

187185
$stepExecution = $this->getStepExecutionMock();
@@ -191,7 +189,7 @@ public function testInvalidReaderExecution()
191189
$this->returnValue(
192190
array(
193191
array(
194-
'reader' => $this->getMock('Oro\Bundle\BatchBundle\Item\ItemReaderInterface'),
192+
'reader' => 'Oro\Bundle\BatchBundle\Item\ItemReaderInterface',
195193
'reason' => 'This is a valid reason.',
196194
'data' => array('foo' => 'bar'),
197195
)
@@ -209,10 +207,8 @@ public function testDoNotLogTwiceTheSameInvalidReaderExecution()
209207
->expects($this->once())
210208
->method('warning')
211209
->with(
212-
$this->matchesRegularExpression(
213-
'/^The .+ was unable to handle the following data: \[foo => bar\] '.
214-
'\(REASON: This is a valid reason\.\)\.$/'
215-
)
210+
'The Oro\Bundle\BatchBundle\Item\ItemReaderInterface was unable ' .
211+
'to handle the following data: [foo => bar] (REASON: This is a valid reason.).'
216212
);
217213

218214
$stepExecution = $this->getStepExecutionMock();
@@ -222,7 +218,7 @@ public function testDoNotLogTwiceTheSameInvalidReaderExecution()
222218
$this->returnValue(
223219
array(
224220
array(
225-
'reader' => $this->getMock('Oro\Bundle\BatchBundle\Item\ItemReaderInterface'),
221+
'reader' => 'Oro\Bundle\BatchBundle\Item\ItemReaderInterface',
226222
'reason' => 'This is a valid reason.',
227223
'data' => array('foo' => 'bar'),
228224
)

Tests/Unit/Step/Stub/ReaderStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ReaderStub implements ItemReaderInterface, StepExecutionAwareInterface
1111
/**
1212
* {@inheritDoc}
1313
*/
14-
public function read(StepExecution $stepExecution)
14+
public function read()
1515
{
1616
}
1717

0 commit comments

Comments
 (0)