| Conditions | 1 |
| Paths | 1 |
| Total Lines | 86 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 69 | public static function providerGetByCards(): iterable |
||
| 70 | { |
||
| 71 | // Test with administrator - should see all domains from accessible cards |
||
| 72 | yield 'administrator sees all domains' => [ |
||
| 73 | 'administrator', |
||
| 74 | [ |
||
| 75 | 'groups' => [ |
||
| 76 | [ |
||
| 77 | 'groupLogic' => 'AND', |
||
| 78 | 'conditionsLogic' => 'AND', |
||
| 79 | 'conditions' => [ |
||
| 80 | [ |
||
| 81 | 'site' => ['equal' => ['value' => Site::Dilps, 'not' => false]], |
||
| 82 | ], |
||
| 83 | [ |
||
| 84 | 'filename' => ['equal' => ['value' => '', 'not' => true]], |
||
| 85 | ], |
||
| 86 | ], |
||
| 87 | ], |
||
| 88 | ], |
||
| 89 | ], |
||
| 90 | [9002, 9003], // Domains from cards 6001, 6002 (both have domains) |
||
| 91 | 'Administrator should see all domains from Dilps cards', |
||
| 92 | ]; |
||
| 93 | |||
| 94 | // Test with junior user (user 1002) - has limited access |
||
| 95 | yield 'junior sees accessible domains' => [ |
||
| 96 | 'junior', |
||
| 97 | [ |
||
| 98 | 'groups' => [ |
||
| 99 | [ |
||
| 100 | 'groupLogic' => 'AND', |
||
| 101 | 'conditionsLogic' => 'AND', |
||
| 102 | 'conditions' => [ |
||
| 103 | [ |
||
| 104 | 'site' => ['equal' => ['value' => Site::Dilps, 'not' => false]], |
||
| 105 | ], |
||
| 106 | [ |
||
| 107 | 'filename' => ['equal' => ['value' => '', 'not' => true]], |
||
| 108 | ], |
||
| 109 | ], |
||
| 110 | ], |
||
| 111 | ], |
||
| 112 | ], |
||
| 113 | [9002], // Junior (user 1002) owns card 6006 with domain 9002, but cannot see private cards 6001, 6002 |
||
| 114 | 'Junior should see only domain from own card, not from private cards', |
||
| 115 | ]; |
||
| 116 | |||
| 117 | // Test with search term filter (complexe query parameters) |
||
| 118 | yield 'filter by search term' => [ |
||
| 119 | 'administrator', |
||
| 120 | [ |
||
| 121 | 'groups' => [ |
||
| 122 | [ |
||
| 123 | 'groupLogic' => 'AND', |
||
| 124 | 'conditionsLogic' => 'AND', |
||
| 125 | 'conditions' => [ |
||
| 126 | [ |
||
| 127 | 'custom' => ['search' => ['value' => 'Test suggestion card 6001']], |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | ], |
||
| 131 | ], |
||
| 132 | ], |
||
| 133 | [9002], // Card 6001 has domain 9002 |
||
| 134 | 'Should return domains from card 6001', |
||
| 135 | ]; |
||
| 136 | |||
| 137 | // Test empty result |
||
| 138 | yield 'no cards match filter' => [ |
||
| 139 | 'administrator', |
||
| 140 | [ |
||
| 141 | 'groups' => [ |
||
| 142 | [ |
||
| 143 | 'groupLogic' => 'AND', |
||
| 144 | 'conditionsLogic' => 'AND', |
||
| 145 | 'conditions' => [ |
||
| 146 | [ |
||
| 147 | 'id' => ['equal' => ['value' => '99999', 'not' => false]], |
||
| 148 | ], |
||
| 149 | ], |
||
| 150 | ], |
||
| 151 | ], |
||
| 152 | ], |
||
| 153 | [], |
||
| 154 | 'Should return empty array when no cards match', |
||
| 155 | ]; |
||
| 158 |