Files
dataflow-bundle/Tests/DataflowType/AbstractDataflowTypeTest.php
T
jeremycr 26ac98eb98 Added CollectionWriter and DelegatorWriter (#34)
* Added CollectionWriter and DelegatorWriter

* Added explanations and examples in README
2019-11-21 11:47:21 +01:00

56 lines
1.7 KiB
PHP

<?php
namespace CodeRhapsodie\DataflowBundle\Tests\DataflowType;
use CodeRhapsodie\DataflowBundle\DataflowType\AbstractDataflowType;
use CodeRhapsodie\DataflowBundle\DataflowType\DataflowBuilder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\OptionsResolver\OptionsResolver;
class AbstractDataflowTypeTest extends TestCase
{
public function testProcess()
{
$label = 'Test label';
$options = ['testOption' => 'Test value'];
$values = [1, 2, 3];
$testCase = $this;
$dataflowType = new class($label, $options, $values, $testCase) extends AbstractDataflowType
{
private $label;
private $options;
private $values;
private $testCase;
public function __construct(string $label, array $options, array $values, TestCase $testCase)
{
$this->label = $label;
$this->options = $options;
$this->values = $values;
$this->testCase = $testCase;
}
public function getLabel(): string
{
return $this->label;
}
protected function configureOptions(OptionsResolver $optionsResolver): void
{
$optionsResolver->setDefined('testOption');
}
protected function buildDataflow(DataflowBuilder $builder, array $options): void
{
$builder->setReader($this->values);
$this->testCase->assertSame($this->options, $options);
}
};
$result = $dataflowType->process($options);
$this->assertSame($label, $result->getName());
$this->assertSame(count($values), $result->getTotalProcessedCount());
}
}