Skip to content

Commit

Permalink
add phpspec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
enesaktay committed Jun 25, 2018
1 parent 21710fd commit 9515d2c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
!/etc/build/.gitkeep

/tests/Application/yarn.lock
/tests/Behat/Resources/fixtures/countries_export.csv

/tests/Behat/Resources/fixtures/export/*
!/tests/Behat/Resources/fixtures/export/.gitkeep
8 changes: 8 additions & 0 deletions spec/Writer/CsvWriterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ function it_delegates_the_data_to_the_wrapped_writer(Writer $csvWriter)
$csvWriter->writeItem($data)->shouldBeCalled();
$this->write($data);
}

function it_finishes_the_file_creation_when_we_get_the_contents(Writer $csvWriter)
{
$csvWriter->setCloseStreamOnFinish(true)->shouldBeCalled();
$csvWriter->getStream()->willReturn(fopen('php://memory', 'w'));
$csvWriter->finish()->shouldBeCalled();
$this->getFileContent();
}
}
2 changes: 2 additions & 0 deletions spec/Writer/ExcelWriterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function it_delegates_the_data_to_the_wrapped_writer(\Port\Excel\ExcelWriter $ex
];
$excelWriter->prepare()->shouldBeCalled();
$excelWriter->writeItem($data)->shouldBeCalled();
$excelWriter->finish()->shouldBeCalled();
$this->write($data);
$this->finish();
}
}
8 changes: 8 additions & 0 deletions src/Exporter/JsonResourceExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ public function setExportFile(string $filename): void
{
$this->filename = $filename;
}

/**
* {@inheritdoc}
*/
public function finish(): void
{
// no finish needed
}
}
2 changes: 1 addition & 1 deletion tests/Behat/Context/CliBaseContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ public function iExportDataToSpecificFiletypeFileWithTheCliCommand($exporterType
$this->application->add($command);
$this->command = $this->application->find('sylius:export');
$this->tester = new CommandTester($this->command);
$this->tester->execute(['command' => 'sylius:export', 'exporter' => $exporterType, 'file' => $this->filePath . '/' . $filename, '--format' => $format]);
$this->tester->execute(['command' => 'sylius:export', 'exporter' => $exporterType, 'file' => $this->filePath . '/export/' . $filename, '--format' => $format]);
}
}
1 change: 0 additions & 1 deletion tests/Behat/Resources/fixtures/countries_export.json

This file was deleted.

0 comments on commit 9515d2c

Please sign in to comment.