From 523850e8879dfa31d919a2abd9ed8399334abf33 Mon Sep 17 00:00:00 2001 From: Andy Newton Date: Thu, 3 Oct 2024 10:43:08 +0100 Subject: [PATCH] feat: test --- .../CommandHandler/DataGovUkExportTest.php | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/app/api/test/module/Cli/src/Domain/CommandHandler/DataGovUkExportTest.php b/app/api/test/module/Cli/src/Domain/CommandHandler/DataGovUkExportTest.php index 052f15c814..95b81e71e0 100644 --- a/app/api/test/module/Cli/src/Domain/CommandHandler/DataGovUkExportTest.php +++ b/app/api/test/module/Cli/src/Domain/CommandHandler/DataGovUkExportTest.php @@ -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 = [ @@ -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';