Skip to content

Commit

Permalink
Merge pull request #282 from vasilvestre/enable-spec
Browse files Browse the repository at this point in the history
Enable spec
  • Loading branch information
oallain authored Dec 21, 2022
2 parents 05375a2 + b3e31ff commit 5d9b00b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion spec/Exporter/ResourceExporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions spec/Exporter/Transformer/PoolSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion spec/Importer/JsonResourceImporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion spec/Importer/ResourceImporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 5d9b00b

Please sign in to comment.