Skip to content
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

[FEATURE]New database factory system #526

Closed
wants to merge 5 commits into from

Conversation

k0ka
Copy link
Contributor

@k0ka k0ka commented Aug 6, 2022

Changes proposed in this pull request:

The new database factory system is added, it was copied from the Laravel Eloquent modern factories https://laravel.com/docs/9.x/database-testing
Everything except Factory relationships has been implemented and works for Doctrine.

The new system is object-oriented, easily extensible, doesn't use any magic files and supports IDE autocompletion.

image

Fixes #470

Changes to be done

Please let me know if this PR looks good, and I'll add documentation (actually copy-paste it from the Laravel).

The current implementation of database factories

While Laravel moved the old factory system into another package laravel/legacy-factories, we might leave it for backward compatibility as both systems can coexist without any problem.

@codecov-commenter
Copy link

codecov-commenter commented Aug 6, 2022

Codecov Report

Merging #526 (3b4b43a) into 1.8 (9eea57d) will increase coverage by 0.82%.
The diff coverage is 66.28%.

@@             Coverage Diff              @@
##                1.8     #526      +/-   ##
============================================
+ Coverage     54.49%   55.32%   +0.82%     
- Complexity      824      889      +65     
============================================
  Files           101      103       +2     
  Lines          2325     2500     +175     
============================================
+ Hits           1267     1383     +116     
- Misses         1058     1117      +59     
Impacted Files Coverage Δ
src/Testing/Factories/Factory.php 66.27% <66.27%> (ø)
src/Testing/Factories/HasEntityFactory.php 66.66% <66.66%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@eigan
Copy link
Member

eigan commented Aug 15, 2022

Looks good to me

k0ka added a commit to k0ka/laravel-doctrine-docs that referenced this pull request Aug 27, 2022
@k0ka
Copy link
Contributor Author

k0ka commented Oct 3, 2022

Please let me know if you have any questions or need any assistance from me.

@esteban-serfe
Copy link

Any news regarding this? should be awesome to have this running....

@eigan eigan changed the base branch from 1.8 to 2.0 December 22, 2023 14:11
@ncphillips
Copy link

Hey all, I'm new to laravel-doctrine but love having good testing utilities. Is there anything we can do to help move this along?

@ncphillips
Copy link

I got fed up with waiting so I made my own package.

https://github.com/nolanos/laravel-doctrine-factory/

I took the approach of literally just subclassing Laravel's Factory class and replacing the eloquent-y bits. Borderline a proof of concept but feel free to give it a shot and report any issues.

@TomHAnderson
Copy link
Contributor

Closing due to #526 (comment)

@sstutz
Copy link
Contributor

sstutz commented Oct 28, 2024

@TomHAnderson would it be possible to just merge @ncphillips package into this repo? The functionality should really be under the "laravel-doctrine" umbrella, reasons being:

  1. it has been part of the package for ages
  2. the current implementation (https://www.laraveldoctrine.org/docs/1.8/orm/testing) broke with the v3 release [1]
  3. ensures compatibility with this package (I can't install the packages because its not compatible with the v3 release)

[1] all my tests that passed with v2 now throw an error "InvalidArgumentException: Unable to locate factory with name [default] [Entity\Name\Space\ClassName]"

@TomHAnderson
Copy link
Contributor

@ncphillips What's your opinion about your factory package? Does it belong as a separate package or do you think it should be a part of this one?

Personally, I like the idea of a separate package. A page in the docs that lists other repos that work alongside this would be useful (e.g. https://webonyx.github.io/graphql-php/complementary-tools/).

@TomHAnderson TomHAnderson reopened this Oct 28, 2024
@ncphillips
Copy link

Hey @TomHAnderson and @sstutz

My understanding was that that's more about integrating laravel with doctrine/orm, so I don't really think the package belongs in laravel-doctrine/orm specificall.

I think it would be reasonable to move it into your Github organization as laravel-doctrine/factory.

The package isn't really ready yet though. It doesn't support m2m relationships and some other things. Probably shouldn't be at v1 yet.

Either way, as long as I was made a maintainer of that repo I would be fine with moving it over. I doubt I'll want to maintain it long term, so being in an org like this would be a good idea.

That said, your call @TomHAnderson

@TomHAnderson
Copy link
Contributor

I won't make a decision at this time. Instead, please continue your work on the project, and if it is useful and does the whole job, I'll consider bringing it to laravel-doctrine.

@TomHAnderson
Copy link
Contributor

Closing this in anticipation of a future issue or PR with a more fully complete implementation of Factory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[QUESTION]Laravel 8 Factories
7 participants