-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save credit memos on server during generation #373
Conversation
GSadee
commented
Jun 29, 2022
Q | A |
---|---|
Branch? | 1.3 |
Bug fix? | no |
New feature? | yes |
Related tickets | fixes #351 |
a363ad3
to
3c9e777
Compare
0f2a1a9
to
5e1260f
Compare
features/pdf_generation_enabled/saving_credit_memos_on_server_during_generation.feature
Show resolved
Hide resolved
private function generatePdf(CreditMemoInterface $creditMemo): void | ||
{ | ||
if (!$this->hasEnabledPdfFileGenerator) { | ||
return; | ||
} | ||
|
||
if (null === $this->creditMemoPdfFileGenerator || null === $this->creditMemoFileManager) { | ||
return; | ||
} | ||
|
||
$creditMemoPdf = $this->creditMemoPdfFileGenerator->generate($creditMemo->getId()); | ||
$this->creditMemoFileManager->save($creditMemoPdf); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already injecting 3 new arguments into this service, also this method does not return anything and is quite independent. Maybe let's create a separate service for generating and saving pdf credit memos and inject it here? It would result in better encapsulation and having only one new argument injected here 🖖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used here the created resolver, as it does what I need, but I have some doubts if this is a proper service, as its name could be misleading 🤔
3ab6208
to
53c32ef
Compare
53c32ef
to
2549553
Compare
/** @test */ | ||
function it_creates_file_in_given_filesystem(): void | ||
{ | ||
$creditMemoFileManager = $this->prepareCreditMemoFileManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could call this function in setUp
method
|
||
$this->assertEquals($creditMemoPdf, $file); | ||
|
||
$this->clearTemporaryDirectory(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this in tearDown
💃
Thanks, Grzegorz! 🥇 |