Comments (6)
@dreamingmind Yes indeed, the Model events are all shutdown when creating the factories. This is made on purpose in order to have the injection in the DB as fast and straighforward as possible.
If you need to test the beforeSave
of your function, I suggest that you write one or several test methods to that aim, where you then save "manually" an entity that you generated unpersisted with the factory. This way, you are really testing the beforeSave
method, and your other unrelated tests will not be unnecessarily slowed down.
I agree that this should be added to the docs.
from cakephp-fixture-factories.
Okay, thanks!
from cakephp-fixture-factories.
Well, I want to toss in one more comment on this issue.
In this particular case, I do have testing for the before filter processes as a separate test. But I am trying to now make test data for a larger process that depends on the existence of a pretty large and complex set of data. The before save process is critical to having all the necessary records exist in a complete and valid state.
It may be possible for me to use the factories to make the records then write more code to back-fill the bits that the event would normally do. But this feels risky.
Would it be practical to have a switch to locally and temporarily turn on the callbacks like the save options and marshaling options?
from cakephp-fixture-factories.
I understand your issue. Per default all model related listeners and behaviors (except from the TimeStamp) are skipped.
Indeed why not enable them if required. I have implemented a static method makeWithModelListenersAndBehaviors
. If you use it instead of make
, you should get what you required.
This also indirectly informs the developer that if he does not choose that method, but make
, the listeners and behaviors will be skipped.
from cakephp-fixture-factories.
Thanks so much! I'll give it a spin
from cakephp-fixture-factories.
That's a wrap. works great
from cakephp-fixture-factories.
Related Issues (20)
- 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
- Truncate Dirty Tables Slowness HOT 2
- Feature Request: Add back-reference property to sub-entities HOT 5
- Error: Column "id" is an identity column defined as GENERATED ALWAYS HOT 1
- Feature Request: Ability to set nested values using `make` method HOT 2
- Enhance array notation
- Calling `with()` inside `setDefaultTemplate()` occurs unexpected increase of the associated entities HOT 4
- phpdoc @param types of `FactoryAwareTrait::getFactory()` is too narrower than acceptable types 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.