metaclass-nl / filter-bundle

Filter bundle for API Platform, Filter Logic
MIT License
50 stars 9 forks source link

Feature/symfony6 and tests #4

Closed art-cg closed 2 years ago

art-cg commented 2 years ago

Hi,

I try to setup the testsuite. But there are some Problems. Could probably be solved in test/App/config/config.yaml but i do not know how to do this right know.

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException : The service "api_platform.doctrine.orm.data_persister" has a dependency on a non-existent service "doctrine". Did you mean one of these: "api_platform.doctrine.orm.data_persister", "api_platform.doctrine.orm.default.collection_data_provider", "api_platform.doctrine.orm.default.item_data_provider", "api_platform.doctrine.orm.default.subresource_data_provider", "api_platform.doctrine.orm.metadata.property.metadata_factory", "api_platform.doctrine.orm.query_extension.eager_loading", "api_platform.doctrine.orm.query_extension.filter", "api_platform.doctrine.orm.query_extension.filter_eager_loading", "api_platform.doctrine.orm.query_extension.pagination", "api_platform.doctrine.orm.query_extension.order"?

How do you execute your test right now?

Greetz

metaclass-nl commented 2 years ago

Hi,

I currently run them within the context of a symfony app, but that is closed source so you can not take a look at it.

This is why there is no test config in the bundle: I figured it could only be tested within the context of a symfony app because the tests use real services. Adding the following config into the testsuites section of phpunit.xml of the app where you use the filter-bundle should make phpunit include them:

        <testsuite name="FilterBundle Test Suite">
            <directory>vendor/metaclass-nl/filter-bundle/tests</directory>
        </testsuite>

Assuming you had composer install the bundle, otherwise you should make it point to the actual location of the bundle.

But with composer you will need composer to include the tests, i guess this means you need to make composer install it with git instead of using some zipped download. I don't have an active memory of how that was been done but i think it was documented at getcomposer.org.

Neverttheless i do agree that i should make it easyer for for everyone to run the tests. My plan would be to make another repo with a minimal symfony app that requirers the bundle in such a way that its tests get installed and has a test config to make them run out of the box. But this will take some time (i mean i will not do it today).

And when i even have even more time i should look into configuring the automated testing of github...

Thanks for bringing all this up! I guess a learned a thing or two about semantic versioning and test configuration. If you have any suggestions please let me know.

art-cg commented 2 years ago

Thanks for this info. Now i can understand how you handle the tests. The creation of GitHub Actions for automated tests is easy for a basic setup. The hard part is the setup of the testsuite and the tests with high coverage itself ;)

metaclass-nl commented 2 years ago

I made a testing app. Making the tests run with PHPUnit 9.5 and Symfony 6.0 took some time. Once the tests where running i knew the FilterBundle intselfs works with Symfony without modification, so i merged your other reques. I think we do not need this one any more, so i close it now. Thanks for your contribution!

art-cg commented 2 years ago

@metaclass-nl Thanks for merging the PR for symfony 6 support. It is up to you if this PR is still needed.