Closed bytes-commerce closed 1 year ago
Hello, As stated in the webapp, the command test generator is a dedicated Laravel test generator. For non Laravel projects, you should always use the BasicTestGenerator (as there is no other framework specific tests generators for now).
How could I possibly contribute by implementing a solution that will work for i.e. Magento2? Right now I rewrite Php Classes via Composer to fit my need (its only a couple of files I had to change to get what I want).
Possibly, the now laravel only functionality could be switched over to a more broad solution that probably will work well with other Frameworks as well.
Hello, Thanks a lot, that's a great idea! I don't add other framework because I don't use them, so I don't think I'd produced great tests skeleton. I think the best way to start is to read the contribution guide and read the existing Laravel tests generators (and other associated implementation). After that, you can fork, create a branch and add new Magento generators on it. Once done (or before if you need help or explanation), you can create a PR! In addition to tests generators, you can also write additional Magento dedicated feature if you want! Thanks a lot, I think it's a great idea, feel free to ask if you need any help.
Link to useful docs or code:
Note: each class is unit tested and there is one or more feature test per feature (eg. a test generator). We follow PSR-2 coding standards, and there is a sonar cloud for code smells.
Lets see, albeit I contribute usually to private Repositories, forking and pushing to existing Repos is new to me. I will read trough it and maybe start something off of it.. From what I learned is that I could perfectly re-use existing code (or better say the code structure) and simply adapt it onto Magento2 needs. I will let you know eventually. :)) Have a nice evening!
Thanks. I'm looking forward to see what you create! Leave a comment if you need anything else!
NB: as this feature is not already available and need your investigation, I leave this issue open until this feature is available inside a release 😉
Hi @nopenopenope, I'm done with your two previous issue (see PRs #24 and #25). Those contains breaking change (new options, interfaces changes) and I'm to release a V3. Do you think your Magento tests generators will introduce other breaking changes? If yes, we'll have to wait for you to finish those before releasing V3. If no, I'll release the V3 soon.
Hi @paul-thebaud thanks for reaching out. I have some challenges going further with my adaptions and will likely take more time to contribute my changes as I like them, so you can already release V3 soon - which would be rather ideal for me, too, since I then could simply move on from there. Thanks a lot of taking care of my suggestions!
It's ok then. I will try to release it this week, but I have some work to prepare on console package and webapp before. I think I will set the typed properties as a default behavior too, since most people are using 7.4+. Thanks you for those suggestions! Still here if you need something 🙂
Hi,
as for your question if there will be breaking changes: likely no. Right now you have the configurable setting in option
array in phpunitgen.php
set to Laravel, and I will likely implement a bridge that also accepts magento2
and does its stuff based on that configuration value (and re-uses other components when possible). So the change itself would rather be minor. The more I work with the code, the less I think it will be an actual "Magento2 Generator" but rather a full grown strict test generator for any Framework without that does nothing much special with the tests, i.e. Sylius or similar.
Hi @nopenopenope,
Yes, the options
key of config is totally made for this! So if you need specific magento config, you can use it like the Laravel user class option.
You can also take a look at DelegateTestGenerator, which choose the most adapted test generator depending on options.context
and class namespace.
Have fun!
Hi @nopenopenope, PhpUnitGen core V3 and console V4 are now released. The webapp is also received as V3 with new configuration on frontend and documentation update. :tada:
Hello @nopenopenope, I'm closing this issue due to no activity. Feel free to reopen if you are still working on it.
Subject of the issue
When
phpunitgen.php
is configured to use PhpUnit over Mockery and the Laravel flag is set to null (apparently, it doesn't matter), PhpUnitGen creates an faulty line in thesetUp()
method.Your environment
phpunitgen/core
: 1phpunitgen/console
: 1.5Steps to reproduce
In
phpunitgen.php
Then, run phpunitgen to create desired tests:
Expected behaviour
The
setUp()
method contains all mocks and creations as expected.Actual behaviour
PhpUnitGen always adds this line of code that will break in my non-laravel environment. Maybe its working in Laravel, tho?
The problematic line is:
as
app
is not an defined property.