Skip to content

Commit

Permalink
feat: improve RatioListCommand (add option "format")
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris8934 committed Jan 30, 2024
1 parent f94e08f commit 0f131df
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Tests/Command/RatioListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,39 @@ public function testCanWriteRatioList(): void
$output = $tester->getDisplay();
self::assertStringContainsString('USD;1.2', $output);
}

public function testGetRatioListAsTable(): void
{
$data = ['EUR' => 1.1, 'USD' => 1.2];
$pairManager = $this->createMock(PairManagerInterface::class);
$pairManager
->expects($this->once())
->method('getRatioList')
->willReturn($data);

$command = new RatioListCommand($pairManager);
$tester = new CommandTester($command);
$tester->execute(['--format' => 'table']);
self::assertSame(Command::SUCCESS, $tester->getStatusCode());
self::assertStringContainsString('EUR | 1.1', $tester->getDisplay());
self::assertStringContainsString('USD | 1.2', $tester->getDisplay());
}

public function testGetRatioListAsJson(): void
{
$data = ['EUR' => 1.1, 'USD' => 1.2];
$pairManager = $this->createMock(PairManagerInterface::class);
$pairManager
->expects($this->once())
->method('getRatioList')
->willReturn($data);

$command = new RatioListCommand($pairManager);
$tester = new CommandTester($command);
$tester->execute(['--format' => 'json']);
self::assertSame(Command::SUCCESS, $tester->getStatusCode());
self::assertJson($tester->getDisplay());
$output = json_decode($tester->getDisplay(), true);
self::assertSame($data, $output);
}
}

0 comments on commit 0f131df

Please sign in to comment.