dereuromark / cakephp-tools

A CakePHP Tools plugin containing lots of useful helpers, behaviors, components, shells, ...
http://www.dereuromark.de
MIT License
336 stars 142 forks source link

Fix TreeHelper problem when type and itemType are both the same #269

Closed LordSimal closed 2 years ago

LordSimal commented 2 years ago

Fixes #267

The problem here was the fact, that simply checking

if ($rType === $type) {

doesn't determine if we are in a type or in a item.

This condition was built upon the fact, that both of these values are never the same.

To fix that I added a 4th parameter to the function which provides us the missing information (since we now where we are when we call the _attribute function)

Also the !empty($elementData['activePathElement']) fixes a warning which popped up for me.

codecov-commenter commented 2 years ago

Codecov Report

Merging #269 (06ec3e3) into master (af2fb41) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #269   +/-   ##
=========================================
  Coverage     78.88%   78.88%           
- Complexity     1830     1831    +1     
=========================================
  Files            62       62           
  Lines          4358     4358           
=========================================
  Hits           3438     3438           
  Misses          920      920           
Impacted Files Coverage Δ
src/View/Helper/TreeHelper.php 82.27% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update af2fb41...06ec3e3. Read the comment docs.

dereuromark commented 2 years ago

Are you able to add a test case for this specific scenario?

LordSimal commented 2 years ago

Sure, let me do that quickly