diff --git a/spec/Exporter/ResourceExporterSpec.php b/spec/Exporter/ResourceExporterSpec.php index 256d5060..f9b97c93 100644 --- a/spec/Exporter/ResourceExporterSpec.php +++ b/spec/Exporter/ResourceExporterSpec.php @@ -40,7 +40,7 @@ function it_should_export_but_also_transform( PluginInterface $plugin ) { $generator = new RewindableGenerator(function () { - return [new DateTimeToStringHandler()]; + yield new DateTimeToStringHandler(); }, $count = 1); $pool = new Pool($generator); diff --git a/spec/Exporter/Transformer/Handler/ArrayToStringHandlerSpec.php b/spec/Exporter/Transformer/Handler/ArrayToStringHandlerSpec.php index e02d2f4a..759a4348 100644 --- a/spec/Exporter/Transformer/Handler/ArrayToStringHandlerSpec.php +++ b/spec/Exporter/Transformer/Handler/ArrayToStringHandlerSpec.php @@ -41,7 +41,7 @@ function it_should_process_via_pool() $array = ['a', 'b', 'c']; $generator = new RewindableGenerator(function () { - return [$this->getWrappedObject()]; + yield $this->getWrappedObject(); }, $count = 1); $pool = new Pool($generator); diff --git a/spec/Exporter/Transformer/Handler/DateTimeToStringHandlerSpec.php b/spec/Exporter/Transformer/Handler/DateTimeToStringHandlerSpec.php index bf3b693e..881011ac 100644 --- a/spec/Exporter/Transformer/Handler/DateTimeToStringHandlerSpec.php +++ b/spec/Exporter/Transformer/Handler/DateTimeToStringHandlerSpec.php @@ -41,7 +41,7 @@ function it_should_process_via_pool() $date = \DateTime::createFromFormat('Y-m-d', '2018-01-01'); $generator = new RewindableGenerator(function () { - return [$this->getWrappedObject()]; + yield $this->getWrappedObject(); }, $count = 1); $pool = new Pool($generator); diff --git a/spec/Exporter/Transformer/Handler/IntegerToMoneyFormatHandlerSpec.php b/spec/Exporter/Transformer/Handler/IntegerToMoneyFormatHandlerSpec.php index 68bea55d..297ba1c0 100644 --- a/spec/Exporter/Transformer/Handler/IntegerToMoneyFormatHandlerSpec.php +++ b/spec/Exporter/Transformer/Handler/IntegerToMoneyFormatHandlerSpec.php @@ -9,6 +9,7 @@ use FriendsOfSylius\SyliusImportExportPlugin\Exporter\Transformer\HandlerInterface; use FriendsOfSylius\SyliusImportExportPlugin\Exporter\Transformer\Pool; use PhpSpec\ObjectBehavior; +use Prophecy\Prophet; use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; use Webmozart\Assert\Assert; @@ -38,12 +39,13 @@ function it_should_process_directly() { $this->handle('test', 10000)->shouldBeString(); $this->handle('test', 12345)->shouldBe('123.45'); + $this->handle('test', 987654)->shouldBe('9876.54'); } function it_should_process_via_pool() { $generator = new RewindableGenerator(function () { - return [$this->getWrappedObject()]; + yield $this->getWrappedObject(); }, $count = 1); $pool = new Pool($generator); diff --git a/spec/Exporter/Transformer/PoolSpec.php b/spec/Exporter/Transformer/PoolSpec.php index e720ff93..2dac51b2 100644 --- a/spec/Exporter/Transformer/PoolSpec.php +++ b/spec/Exporter/Transformer/PoolSpec.php @@ -24,8 +24,8 @@ function it_should_implement_interface() function let(HandlerInterface $dateTimeToStringHandler) { - $generator = new RewindableGenerator(function () use ($dateTimeToStringHandler) { - return [$dateTimeToStringHandler]; + $generator = new RewindableGenerator(function () use ($dateTimeToStringHandler): \Traversable { + yield $dateTimeToStringHandler; }, $count = 1); $this->beConstructedWith($generator); diff --git a/spec/Importer/JsonResourceImporterSpec.php b/spec/Importer/JsonResourceImporterSpec.php index 5d826119..61e9e66c 100644 --- a/spec/Importer/JsonResourceImporterSpec.php +++ b/spec/Importer/JsonResourceImporterSpec.php @@ -4,7 +4,7 @@ namespace spec\FriendsOfSylius\SyliusImportExportPlugin\Importer; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterResultInterface; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImportResultLoggerInterface; use FriendsOfSylius\SyliusImportExportPlugin\Importer\JsonResourceImporter; diff --git a/spec/Importer/ResourceImporterSpec.php b/spec/Importer/ResourceImporterSpec.php index 0ebc28f4..3b3f9428 100644 --- a/spec/Importer/ResourceImporterSpec.php +++ b/spec/Importer/ResourceImporterSpec.php @@ -4,7 +4,7 @@ namespace spec\FriendsOfSylius\SyliusImportExportPlugin\Importer; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\Persistence\ObjectManager; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterInterface; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterResultInterface; use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImportResultLoggerInterface; diff --git a/src/Exporter/Transformer/Handler/IntegerToMoneyFormatHandler.php b/src/Exporter/Transformer/Handler/IntegerToMoneyFormatHandler.php index 280ac674..eb11597e 100644 --- a/src/Exporter/Transformer/Handler/IntegerToMoneyFormatHandler.php +++ b/src/Exporter/Transformer/Handler/IntegerToMoneyFormatHandler.php @@ -17,7 +17,7 @@ final class IntegerToMoneyFormatHandler extends Handler /** * @param string[] $allowedKeys */ - public function __construct(array $allowedKeys, string $format = '%.2n') + public function __construct(array $allowedKeys, string $format = '%0.2f') { $this->keys = $allowedKeys; $this->format = $format; @@ -28,7 +28,7 @@ public function __construct(array $allowedKeys, string $format = '%.2n') */ protected function process($key, $value): ?string { - return money_format($this->format, $value / 100); + return sprintf($this->format, $value / 100); } protected function allows($key, $value): bool