Closed jissereitsma closed 3 years ago
As a remark: I've never bumped into this issue myself, because I've been using separate DataProvider classes myself - I always disliked the linear and hacky way of doing things in a fixture file, without much OOP to organize your code. So, I'm just using setUp
to include a certain data provider and then call upon its methods within my own test methods to generate whatever I want to generate: The database transaction rollbacks work just fine for this.
Thanks for checking - yes this was indeed the issue I mentioned around paths that I ran into (forgot it only applied to custom fixture files). For 2.3.2 there is now also this.
Ah cool thing - same solution but then in the core!
(close when you feel to)
The ExtDN integration test Github action is now live in this repo https://github.com/fooman/printorderpdf-implementation-m2/runs/1223989056?check_suite_focus=true
When trying to run the integration tests in this module (as we discussed earlier :)) I wanted to take this the easy route - no copying of files, just a composer install, a modification of the PHPUnit file and done:
This worked, up to the point of fixtures causing havoc. This issue is already discussed here: https://magento.stackexchange.com/questions/93422/creating-integration-tests-for-magento-2-modules/104897#104897 The solution that Fabian suggests is solid but had some minor issues. I'll just go through the steps I took here (without a PR).
The trick of Fabian was to add
@magentoDataFixture loadFixture
whereloadFixture
is not a file but a method name. However, his sample method does not work with a simple__DIR__
because that is pointing towards the TestFramework folder and not the current folder. I just used the ComponentRegistrar to get me where I wanted:The path to the fixture is a bit insane, but this can maybe improved a bit (
tests/integration/testsuite/Fooman/PrintOrderPdf/_files
?).In the file
tests/integration/testsuite/Fooman/PrintOrderPdf/Block/Adminhtml/_files/order.php
I removed the inclusion of the Magento core fixture (require
). We can simply use a DocBlock@magentoDataFixture Magento/Sales/_files/order.php
for this in thePrintOrderButtonTest
class:After this, running the test works as expected: Nothing being copied to
dev/tests/integration
but just a generic PHPUnit file that points to Fooman folders.