# |
Sep 3rd 2019, 11:27 |
slackebot |
correttamente’)); return $this->redirect([‘controller’ => ‘groups’, ‘action’ => ‘index’]); } else { $this->conn->rollback(); $this->Flash->error(__(‘Si e\’ verificato un errore durante l\‘associazione delle capabilities. Riprovare di nuovo.’)); } |
# |
Sep 3rd 2019, 11:27 |
slackebot |
$this->Groups->get($groupId, [‘contain’ => [‘Capabilities’]]); $patchEntityVar = $this->Groups->patchEntity($group, $finalCapabilities); $this->log($this->Groups->Permissions->save($group), ‘debug’); if($this->Groups->save($group)){ \Cake\Cache\Cache::clearGroup(‘user_groups’, ‘user_groups’); $this->conn->commit(); $this->Flash->success(__(‘Capabilitie |
# |
Sep 3rd 2019, 11:27 |
peppejaripappalardo |
Hello guys, Just a little help: i have a table called groups, that have associations belongsToMany to Capabilities, that join permission table. When i do save of groups I need also to save capabilities. In groups I have: id, description. In permission I have: group_id and capability_id, when I do the patchEntity i need to save the new record in permission. This is the code into the controller: $group = |
# |
Sep 3rd 2019, 11:21 |
neon1024 |
I usually find I’ve accidentally preserved state somewhere |
# |
Sep 3rd 2019, 11:21 |
neon1024 |
Oh I hate those! |
# |
Sep 3rd 2019, 11:21 |
conehead |
Although one tests fails now....and only if I run all tests at the same time :P |
# |
Sep 3rd 2019, 11:19 |
spriz |
Rocking the world AFAIK :the_horns: |
# |
Sep 3rd 2019, 11:18 |
neon1024 |
I wonder what @jippi is doing these days |
# |
Sep 3rd 2019, 11:18 |
spriz |
it's amazing |
# |
Sep 3rd 2019, 11:18 |
neon1024 |
Nice plugin @spriz didn’t know about that one |
# |
Sep 3rd 2019, 11:17 |
conehead |
Or just load all fixtures once |
# |
Sep 3rd 2019, 11:17 |
conehead |
Even better...I do not need to load fixtures anymore! |
# |
Sep 3rd 2019, 11:16 |
spriz |
Yay! |
# |
Sep 3rd 2019, 11:16 |
conehead |
@spriz fixturize seems to work like a charm! |
# |
Sep 3rd 2019, 11:14 |
spriz |
I just use xdebug that once a month when I really need a debugger and I know it slows shit down :) |
# |
Sep 3rd 2019, 11:13 |
spriz |
personally not using coverage ¯\_(ツ)_/¯ |
# |
Sep 3rd 2019, 11:13 |
spriz |
Ah, that might be! :) |
# |
Sep 3rd 2019, 11:12 |
admad |
@spriz don't use xdebug even if you need coverage, use pcov :slightly_smiling_face: |
# |
Sep 3rd 2019, 11:04 |
conehead |
Usually I got xdebug disabled |
# |
Sep 3rd 2019, 11:04 |
conehead |
I will have a look at fixturize. Thanks |
# |
Sep 3rd 2019, 11:04 |
spriz |
With `vendor/bin/phpunit --no-coverage` though |
# |
Sep 3rd 2019, 11:03 |
spriz |
We have ~150 fixtures with 450 tests and 1500 assertions and the full suite is 3:31 :slightly_smiling_face: |
# |
Sep 3rd 2019, 11:01 |
spriz |
and ofc you should not run your tests with `xdebug` enabled unless you need the coverage |
# |
Sep 3rd 2019, 11:00 |
spriz |
it basically only destroy/re-create fixtures if any data has changed from previous test |
# |
Sep 3rd 2019, 11:00 |
spriz |
that is like 3-4x improvement for our saas suite |
# |
Sep 3rd 2019, 11:00 |
spriz |
Aha! Did you try https://github.com/FriendsOfCake/fixturize ? |
# |
Sep 3rd 2019, 10:59 |
conehead |
ah testing against agains actual sql |
# |
Sep 3rd 2019, 10:59 |
spriz |
yeah but unless you changed stuff, that fixtures are creating tables/data in a sql db |
# |
Sep 3rd 2019, 10:59 |
spriz |
or some in-memory thing? |
# |
Sep 3rd 2019, 10:59 |
conehead |
no, just fixtures |
# |
Sep 3rd 2019, 10:59 |
spriz |
@conehead do you have it backed by an actual SQL db? |
# |
Sep 3rd 2019, 10:52 |
conehead |
Just trying to raise the code coverage to > 80%. And usually I like to run all tests before committing. Sucks a little if it takes ages |
# |
Sep 3rd 2019, 10:51 |
conehead |
Yes that is what I am trying to do :P |
# |
Sep 3rd 2019, 10:49 |
neon1024 |
They’re your tests! If you’re confident in your suite, make your changes :slightly_smiling_face: |
# |
Sep 3rd 2019, 10:49 |
conehead |
The controller just does stuff in the background I don't care about |
# |
Sep 3rd 2019, 10:49 |
neon1024 |
Yep, one of my projects the test suite takes 30 minutes |
# |
Sep 3rd 2019, 10:48 |
conehead |
Just doing normal controller tests. But already takes like 10 minutes now |
# |
Sep 3rd 2019, 10:48 |
neon1024 |
Has anyone tried to use `riesenia/cakephp-duplicatable` with hasMany? I’d like to duplicate my hasMany records, but trying to unset the association `id` fields is causing a headache |
# |
Sep 3rd 2019, 10:45 |
neon1024 |
So you can load your dashboard and test `->canSee('#user-details')` etc |
# |
Sep 3rd 2019, 10:45 |
neon1024 |
Using something like Codeception |
# |
Sep 3rd 2019, 10:45 |
neon1024 |
Perhaps you’re looking for acceptance tests? |