# |
May 3rd 2019, 14:21 |
maymeow |
Just need to ensure that in time of test in database exists everything what I need (in my case user article and profile) |
# |
May 3rd 2019, 14:20 |
maymeow |
Hmm |
# |
May 3rd 2019, 14:20 |
neon1024 |
Depends how much time you have to maintain a test suite I suppose |
# |
May 3rd 2019, 14:20 |
neon1024 |
You could assert getTarget(), getSource() etc I suppose |
# |
May 3rd 2019, 14:19 |
neon1024 |
etc |
# |
May 3rd 2019, 14:19 |
neon1024 |
`$this->assertSame($result->getClassName(), 'Users')` |
# |
May 3rd 2019, 14:18 |
neon1024 |
`$this->assertInstanceOf($result, \Cake\ORM\Association::class)` |
# |
May 3rd 2019, 14:17 |
neon1024 |
..and assert the response |
# |
May 3rd 2019, 14:17 |
neon1024 |
The unit test for the association would literally be `$articlesTable->getAssociation('Users')` |
# |
May 3rd 2019, 14:16 |
maymeow |
I never used codeception before |
# |
May 3rd 2019, 14:16 |
neon1024 |
..and you have an acceptance test-case to ensure that there is a profile data in the article view template |
# |
May 3rd 2019, 14:15 |
neon1024 |
You have a test-case to ensure there is an association between Articles and Users |
# |
May 3rd 2019, 14:15 |
neon1024 |
Or it sounds like two tests |
# |
May 3rd 2019, 14:15 |
neon1024 |
We use Codeception for that |
# |
May 3rd 2019, 14:15 |
neon1024 |
Sounds like an acceptance test |
# |
May 3rd 2019, 14:14 |
maymeow |
For example test article view that belongs to user ... User need to have profile which is showing on page otherwise I'll f profile missing it's return error 500 |
# |
May 3rd 2019, 14:12 |
neon1024 |
I can’t see why you’d want to test a model association anyway |
# |
May 3rd 2019, 14:12 |
neon1024 |
I don’t know what that is, sorry |
# |
May 3rd 2019, 14:12 |
maymeow |
It would be good to have something like laravel factories for testing :) @neon1024 |
# |
May 3rd 2019, 13:54 |
neon1024 |
Which would be more of an integration test, but would be less fragile |
# |
May 3rd 2019, 13:54 |
neon1024 |
Or I’d build a query object, with contains and assert that the query object contained the correct associations |
# |
May 3rd 2019, 13:53 |
neon1024 |
Then I’d update my test every single time I changed an association in that table |
# |
May 3rd 2019, 13:53 |
neon1024 |
If I needed to test an association, I would just read the association config array and assert it |
# |
May 3rd 2019, 13:47 |
maymeow |
Is there any good practices how to test model with relationships??? (fixtures don't have relations defined).. it is defined here user_id for example but if i need remove id from related fixture because of postgres test its not relevant. how do you guys testing actions that reqire related models? |
# |
May 3rd 2019, 12:40 |
Arckame |
thank you |
# |
May 3rd 2019, 12:39 |
Arckame |
but i will try a plugin, my first idea was probably not the best. |
# |
May 3rd 2019, 12:39 |
Arckame |
yep, but working as a plugin, I had in mind something like create a Database/Driver/<driver>.php in my src folder. |
# |
May 3rd 2019, 12:36 |
admad |
Arckame: that's how https://github.com/CakeDC/cakephp-oracle-driver :slightly_smiling_face: |
# |
May 3rd 2019, 12:33 |
Arckame |
Any idea about how to properly implement a new database driver in Cake 3.7 ? |
# |
May 3rd 2019, 12:30 |
Arckame |
hello |
# |
May 3rd 2019, 11:55 |
admad |
@kgb.acct.personal you can't change the query string variable. You would have to use your own paginator class and helper for that |
# |
May 3rd 2019, 11:54 |
martin |
I was unable to find it, also checked the saved entity but also not in there |
# |
May 3rd 2019, 11:53 |
admad |
it should be within that entity |
# |
May 3rd 2019, 11:53 |
martin |
hmm it is a validation error in a relation. That should also be showed there I guess? |
# |
May 3rd 2019, 11:48 |
martin |
I hate errors like this, it has an error during save, but it does not tell what the error is :( |
# |
May 3rd 2019, 11:21 |
noel |
@waspinator thanks for the stackoverflow link.. that’s a self-referencing many-to-one association though, not many-to-many |
# |
May 3rd 2019, 09:14 |
spriz |
Oh well, that will work just fine! Thanks :) |
# |
May 3rd 2019, 09:12 |
spriz |
:cold_sweat: |
# |
May 3rd 2019, 09:12 |
neon1024 |
TIL |
# |
May 3rd 2019, 09:11 |
neon1024 |
> a character symbolizing the idea of a thing without indicating the sounds used to say it. Examples include numerals and Chinese characters. |
# |
May 3rd 2019, 09:11 |
neon1024 |
I wonder what an ‘ideograph’ is :thinking_face: |