Comments (6)
Ok i will try that.
I added the OrdersProducts relationship because i had problems with created modified when doing :
->with('Products[5]')
I'll do some test and come back to you soon.
from cakephp-fixture-factories.
Hi @Drfloo,
chaining associations is definitely supported by the package.
Here is an example aiming at reproducing the scenario you propose: https://github.com/vierge-noire/cakephp-fixture-factories/blob/main/tests/TestCase/Factory/BaseFactoryAssociationsTest.php#L690
Could the issue come from the definition of your associations?
from cakephp-fixture-factories.
Hi ! Thanks a lot Juan !
It's weird that it's not working for me.
Here's my relations for OrdersTable :
$this->hasMany('OrdersProducts');
$this->belongsToMany('Products');
$this->belongsTo('ShippingServices', [
'foreignKey' => 'shipping_service_id',
]);
from cakephp-fixture-factories.
I am a bit clueless. I have added a second test here, that reproduces even more closely your relations set:
https://github.com/vierge-noire/cakephp-fixture-factories/blob/next/tests/TestCase/Factory/BaseFactoryAssociationsTest.php#L714
Generally in your case I would get rid of the OrdersProducts
association, as it is trivial, and use only the Products
association. That might help...
from cakephp-fixture-factories.
->with('Products', 5)
works too and is a bit faster to write, imo.
from cakephp-fixture-factories.
Following your pm, if you have issues with date stamp fields, you may add them in the default template of your factories, so they get populated by default.
This is generally not necessary, as illustrated in this test, but I have seen a few setups where this was required.
from cakephp-fixture-factories.
Related Issues (20)
- load the plugin only on dev mode HOT 2
- Factory for association of a loaded plugin HOT 9
- test pass / fail based on other tests HOT 11
- In string method notation HOT 6
- Set display field if field is not defined
- Code checker should check and fix imports
- Fix test pipelines for lowest dependencies
- Skip cake entity setter when set fields data HOT 5
- How to specify database connection other than `test`? HOT 1
- How to nest ->with() HOT 2
- Feature requests: Enhancements to configuration HOT 6
- Recurrent PersistenceExceptions thrown in factories due to Primary Key collisions HOT 6
- Fix Psalm
- Composer require no DB cleaner
- Calling fixture factories for a table breaks application code that uses that table downstream HOT 4
- Primary key of type text should generate UUID HOT 1
- What is the mergeAssociated(array $data) function for? HOT 1
- Testing simple method without persisting data HOT 1
- fakerphp 8.2 warnings HOT 1
- Creating multiple translations using shadowStrategy HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cakephp-fixture-factories.