Skip to content

Commit

Permalink
feat: test
Browse files Browse the repository at this point in the history
  • Loading branch information
fibble committed Oct 3, 2024
1 parent decccdb commit 523850e
Showing 1 changed file with 0 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ public function testInvalidReportException()

public function testInternationalGoods()
{
$mockDateTime = \Mockery::mock('overload:Dvsa\Olcs\Api\Domain\Util\DateTime\DateTime');
$mockDateTime->shouldReceive('format')
->with(DataGovUkExport::FILE_DATETIME_FORMAT)
->andReturn('20241003_081706');

$fileName = 'international_goods';

$row1 = [
Expand Down Expand Up @@ -212,55 +207,20 @@ public function testInternationalGoods()

$actual = $this->sut->handleCommand($cmd);

$vfsFiles = $this->listVfsFiles();
echo "Files in VFS:\n" . implode("\n", $vfsFiles) . "\n";

$date = new DateTime('now');
$expectedFile = $this->tmpPath . '/' . $fileName . '_' .
$date->format(DataGovUkExport::FILE_DATETIME_FORMAT) . '.csv';

echo "Expected file: $expectedFile\n";


$expectMsg =
'Fetching data for international goods list' .
'Creating CSV file: ' . $expectedFile;

$fileContent = $this->vfsStream->getChild('unit/' . basename($expectedFile))->getContent();

$this->assertSame(
'"Licence number",col1,col2' . "\n" .
'LicNo1,val11,"v""\'-/\,"' . "\n" .
'LicNo2,val21,val22' . "\n" .
'LicNo3,val31,val32' . "\n",
$fileContent
);

$this->assertEquals(
$expectMsg,
implode('', $actual->toArray()['messages'])
);
}

private function listVfsFiles($dir = '')
{
$result = [];
$root = $this->vfsStream->getChild($dir);

if ($root instanceof vfsStreamDirectory) {
foreach ($root->getChildren() as $child) {
$path = $dir ? "$dir/" . $child->getName() : $child->getName();
if ($child instanceof vfsStreamDirectory) {
$result = array_merge($result, $this->listVfsFiles($path));
} else {
$result[] = $path;
}
}
}

return $result;
}

public function testPsvOperatorListOk()
{
$fileName = 'psv-operator-list.csv';
Expand Down

0 comments on commit 523850e

Please sign in to comment.