Open pabloelcolombiano opened 2 years ago
Hello there,
I saw in your tests that you might be having issue using the fixture factories. Let me know if I can assist you to put this in place!
Hello, if it's good with you it will be my pleasure !
Sure. What was the issue you encountered?
Sure. What was the issue you encountered?
Well i was trying to use the fixture Factory to mock the data in my database, but when i read the doc i understand that the way CakePHP used the Fixture i would need a test database. So after that i tried to do the fixture myself a tried it with FixtureFactory. It worked for one of my table but not the other, even with the fact that i did the same thing. Do it actually possible to mock the database with Fixture Factory ? Thank for your time.
There is no "mocking of the database" as such.
If you have an error message or something to help debugging, let me know, I'll try to help you.
There is no "mocking of the database" as such.
- You first need a test database, and set it up as described here. This is no mocking, it is a second database, identical to the productive one, but dedicated to the tests.
- Once this is done, you can write your tests. If this worked with one factory, there is no reason it should not work with the second (and the third, etc)
If you have an error message or something to help debugging, let me know, I'll try to help you.
Hello, thank for the quick answer. It's a shame that mock dosen't exist but well. Guess i need to find another way to do the test with Ghitub actions. I'm not really sure why the second test didn't work, at first CakePHP tell me that he was searching a tables en the test database but with a extra s. My table name is "produit" but CakePHP search "produits" so he can't find it. I almost forget one of the most troublesome problem, dosen't the fixture create the table, insert the test datas, and clear everything after the test ? Because for me he only insert the datas. That's all.
Thank for your time
DELETE FROM users WHERE deleted = 1;
has a different impact as DELETE FROM users;
. So no, it is not a shame ;-)
- Mocking the database is not desired - you want to test the queries you've written. E.g.
DELETE FROM users WHERE deleted = 1;
has a different impact asDELETE FROM users;
. So no, it is not a shame ;-)- I highly recommend you to follow the CakePHP naming conventions, by naming your tables in English plural. Though this is not a requirement, it will facilitate your development experience. If you must stick to french singular table names, I would need more input on the error triggered to help you. This might well not be related to the factories.
- The fixture factories do not create the tables, nor clear anything in the DB. It does insert test data, if persistence is demanded.
- The management of the schema (crating the tables) is handled by the Migrator (either from vierge-noire if CakePHP<4.3, or from Cake if CakePHP >4.3). If you have installed the test suite light, the dirty tables get cleared before each test, and not after.
Hello,
Hello there,
I saw in your tests that you might be having issue using the fixture factories. Let me know if I can assist you to put this in place!