Skip to content

Commit

Permalink
happy new year - unit tests for exchange factory
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Jan 1, 2024
1 parent cc53146 commit 5cf8617
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Bundles/Exchange/ExchangeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getAllOptions(): array
*/
public function getExchange(string $format, array $options): ExchangeInterface
{
if ($format === '' || $format === '0') {
if ($format === '') {
throw new Exception('No format name provided for the Exchange service');
}

Expand Down
15 changes: 15 additions & 0 deletions tests/phpunit/Bundles/Exchange/ExchangeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use phpunit\Utils\Fakes\FakeExchangeFormat;
use PHPUnuhi\Bundles\Exchange\ExchangeFactory;
use PHPUnuhi\Exceptions\ConfigurationException;
use PHPUnuhi\Models\Command\CommandOption;

class ExchangeFactoryTest extends TestCase
{
Expand Down Expand Up @@ -69,4 +70,18 @@ public function testEmptyFormatThrowsException(): void

ExchangeFactory::getInstance()->getExchange('', []);
}

/**
*
*/
public function testGetAllOptions(): void
{
$options = ExchangeFactory::getInstance()->getAllOptions();

$expected = [
new CommandOption('csv-delimiter', true),
];

$this->assertEquals($expected, $options);
}
}

0 comments on commit 5cf8617

Please sign in to comment.