We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Total Complexity | 40 |
| Total Lines | 538 |
| Duplicated Lines | 0 % |
| Changes | 6 | ||
| Bugs | 4 | Features | 1 |
Complex classes like CrudPanelReadTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use CrudPanelReadTest, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 13 | class CrudPanelReadTest extends BaseDBCrudPanelTest |
||
| 14 | { |
||
| 15 | private $relationshipColumn = [ |
||
| 16 | 'name' => 'user_id', |
||
| 17 | 'type' => 'select', |
||
| 18 | 'entity' => 'user', |
||
| 19 | 'attribute' => 'name', |
||
| 20 | ]; |
||
| 21 | |||
| 22 | private $relationshipMultipleColumn = [ |
||
|
|
|||
| 23 | 'name' => 'roles', |
||
| 24 | 'type' => 'select', |
||
| 25 | 'entity' => 'roles', |
||
| 26 | 'attribute' => 'name', |
||
| 27 | 'model' => Role::class, |
||
| 28 | ]; |
||
| 29 | |||
| 30 | private $nonRelationshipColumn = [ |
||
| 31 | 'name' => 'field1', |
||
| 32 | 'label' => 'Field1', |
||
| 33 | ]; |
||
| 34 | |||
| 35 | private $articleFieldsArray = [ |
||
| 36 | [ |
||
| 37 | 'name' => 'content', |
||
| 38 | 'label' => 'The Content', |
||
| 39 | 'type' => 'text', |
||
| 40 | ], |
||
| 41 | [ |
||
| 42 | 'name' => 'metas', |
||
| 43 | 'label' => 'Metas', |
||
| 44 | ], |
||
| 45 | [ |
||
| 46 | 'name' => 'tags', |
||
| 47 | ], |
||
| 48 | [ |
||
| 49 | 'name' => 'extras', |
||
| 50 | ], |
||
| 51 | ]; |
||
| 52 | |||
| 53 | private $expectedCreateFormArticleFieldsArray = [ |
||
| 54 | 'content' => [ |
||
| 55 | 'name' => 'content', |
||
| 56 | 'label' => 'The Content', |
||
| 57 | 'type' => 'text', |
||
| 58 | ], |
||
| 59 | 'metas' => [ |
||
| 60 | 'name' => 'metas', |
||
| 61 | 'label' => 'Metas', |
||
| 62 | 'type' => 'text', |
||
| 63 | ], |
||
| 64 | 'tags' => [ |
||
| 65 | 'name' => 'tags', |
||
| 66 | 'label' => 'Tags', |
||
| 67 | 'type' => 'text', |
||
| 68 | ], |
||
| 69 | 'extras' => [ |
||
| 70 | 'name' => 'extras', |
||
| 71 | 'label' => 'Extras', |
||
| 72 | 'type' => 'text', |
||
| 73 | ], |
||
| 74 | ]; |
||
| 75 | |||
| 76 | private $expectedUpdateFormArticleFieldsArray = [ |
||
| 77 | 'content' => [ |
||
| 78 | 'name' => 'content', |
||
| 79 | 'label' => 'The Content', |
||
| 80 | 'type' => 'text', |
||
| 81 | 'value' => 'Some Content', |
||
| 82 | ], |
||
| 83 | 'metas' => [ |
||
| 84 | 'name' => 'metas', |
||
| 85 | 'label' => 'Metas', |
||
| 86 | 'type' => 'text', |
||
| 87 | 'value' => '{"meta_title":"Meta Title Value","meta_description":"Meta Description Value"}', |
||
| 88 | ], |
||
| 89 | 'tags' => [ |
||
| 90 | 'name' => 'tags', |
||
| 91 | 'label' => 'Tags', |
||
| 92 | 'type' => 'text', |
||
| 93 | 'value' => '{"tags":["tag1","tag2","tag3"]}', |
||
| 94 | ], |
||
| 95 | 'extras' => [ |
||
| 96 | 'name' => 'extras', |
||
| 97 | 'label' => 'Extras', |
||
| 98 | 'type' => 'text', |
||
| 99 | 'value' => '{"extra_details":["detail1","detail2","detail3"]}', |
||
| 100 | ], |
||
| 101 | 'id' => [ |
||
| 102 | 'name' => 'id', |
||
| 103 | 'type' => 'hidden', |
||
| 104 | 'value' => 1, |
||
| 105 | ], |
||
| 106 | ]; |
||
| 107 | |||
| 108 | private $uploadField = [ |
||
| 109 | 'name' => 'image', |
||
| 110 | 'label' => 'Image', |
||
| 111 | 'type' => 'upload', |
||
| 112 | 'upload' => true, |
||
| 113 | ]; |
||
| 114 | |||
| 115 | private $multipleUploadField = [ |
||
| 116 | 'name' => 'photos', |
||
| 117 | 'label' => 'Photos', |
||
| 118 | 'type' => 'upload_multiple', |
||
| 119 | 'upload' => true, |
||
| 120 | ]; |
||
| 121 | |||
| 122 | private $defaultPaginator = [[10, 20, 30], ['t1', 't2', 't3']]; |
||
| 123 | |||
| 124 | public function testGetEntry() |
||
| 125 | { |
||
| 126 | $this->crudPanel->setModel(User::class); |
||
| 127 | $user = User::find(1); |
||
| 128 | |||
| 129 | $entry = $this->crudPanel->getEntry($user->id); |
||
| 130 | |||
| 131 | $this->assertEquals($user, $entry); |
||
| 132 | } |
||
| 133 | |||
| 134 | public function testGetEntryWithFakes() |
||
| 135 | { |
||
| 136 | $this->markTestIncomplete('Not correctly implemented'); |
||
| 137 | |||
| 138 | $this->crudPanel->setModel(Article::class); |
||
| 139 | $article = Article::find(1); |
||
| 140 | |||
| 141 | $entry = $this->crudPanel->getEntry($article->id); |
||
| 142 | |||
| 143 | // TODO: the withFakes call is needed for this to work. the state of the model should not be changed by the |
||
| 144 | // getEntry method. the transformation of the fakes columns should be kept in a different crud panel |
||
| 145 | // attribute or, at most, the getEntry method should be renamed. |
||
| 146 | $article->withFakes(); |
||
| 147 | |||
| 148 | $this->assertEquals($article, $entry); |
||
| 149 | } |
||
| 150 | |||
| 151 | public function testGetEntryExists() |
||
| 152 | { |
||
| 153 | $this->crudPanel->setModel(User::class); |
||
| 154 | $userEntry = $this->crudPanel->getEntry(1); |
||
| 155 | |||
| 156 | $this->assertInstanceOf(User::class, $userEntry); |
||
| 157 | |||
| 158 | $this->crudPanel->setModel(Article::class); |
||
| 159 | $articleEntry = $this->crudPanel->getEntry(1); |
||
| 160 | |||
| 161 | $this->assertInstanceOf(Article::class, $articleEntry); |
||
| 162 | } |
||
| 163 | |||
| 164 | public function testGetEntryUnknownId() |
||
| 165 | { |
||
| 166 | $this->expectException(ModelNotFoundException::class); |
||
| 167 | |||
| 168 | $this->crudPanel->setModel(User::class); |
||
| 169 | |||
| 170 | $unknownId = DB::getPdo()->lastInsertId() + 2; |
||
| 171 | $this->crudPanel->getEntry($unknownId); |
||
| 172 | } |
||
| 173 | |||
| 174 | public function testAutoEagerLoadRelationshipColumns() |
||
| 175 | { |
||
| 176 | $this->crudPanel->setModel(Article::class); |
||
| 177 | $this->crudPanel->setOperation('list'); |
||
| 178 | $this->crudPanel->addColumn($this->relationshipColumn); |
||
| 179 | |||
| 180 | $this->crudPanel->autoEagerLoadRelationshipColumns(); |
||
| 181 | |||
| 182 | $this->assertArrayHasKey('user', $this->crudPanel->query->getEagerLoads()); |
||
| 183 | } |
||
| 184 | |||
| 185 | public function testAutoEagerLoadRelationshipColumnsNoRelationships() |
||
| 186 | { |
||
| 187 | $this->crudPanel->setModel(Article::class); |
||
| 188 | $this->crudPanel->addColumn($this->nonRelationshipColumn); |
||
| 189 | |||
| 190 | $this->crudPanel->autoEagerLoadRelationshipColumns(); |
||
| 191 | |||
| 192 | $this->assertEmpty($this->crudPanel->query->getEagerLoads()); |
||
| 193 | } |
||
| 194 | |||
| 195 | public function testGetEntries() |
||
| 196 | { |
||
| 197 | $this->crudPanel->setModel(User::class); |
||
| 198 | |||
| 199 | $entries = $this->crudPanel->getEntries(); |
||
| 200 | |||
| 201 | $this->assertInstanceOf(Collection::class, $entries); |
||
| 202 | $this->assertEquals(2, $entries->count()); |
||
| 203 | $this->assertEquals(User::find(1), $entries->first()); |
||
| 204 | } |
||
| 205 | |||
| 206 | public function testGetEntriesWithFakes() |
||
| 207 | { |
||
| 208 | $this->markTestIncomplete('Not correctly implemented'); |
||
| 209 | |||
| 210 | $this->crudPanel->setModel(Article::class); |
||
| 211 | |||
| 212 | $entries = $this->crudPanel->getEntries(); |
||
| 213 | |||
| 214 | // TODO: the getEntries method automatically adds fakes. the state of the models should not be changed by the |
||
| 215 | // getEntries method. at most, the getEntries method should be renamed. |
||
| 216 | $this->assertInstanceOf(Collection::class, $entries); |
||
| 217 | $this->assertEquals(1, $entries->count()); |
||
| 218 | $this->assertEquals(Article::find(1), $entries->first()); |
||
| 219 | } |
||
| 220 | |||
| 221 | public function testGetFieldsCreateForm() |
||
| 222 | { |
||
| 223 | $this->crudPanel->addFields($this->articleFieldsArray); |
||
| 224 | |||
| 225 | // TODO: update method documentation. the $form parameter does not default to 'both'. |
||
| 226 | $fields = $this->crudPanel->getFields('create'); |
||
| 227 | |||
| 228 | $this->assertEquals($this->expectedCreateFormArticleFieldsArray, $fields); |
||
| 229 | } |
||
| 230 | |||
| 231 | public function testGetFieldsUpdateForm() |
||
| 232 | { |
||
| 233 | $this->crudPanel->setModel(Article::class); |
||
| 234 | |||
| 235 | $this->crudPanel->setOperation('update'); |
||
| 236 | $this->crudPanel->addFields($this->articleFieldsArray); |
||
| 237 | |||
| 238 | // TODO: update method documentation. the $form parameter does not default to 'both'. |
||
| 239 | $fields = $this->crudPanel->getUpdateFields(1); |
||
| 240 | |||
| 241 | $this->assertEquals($this->expectedUpdateFormArticleFieldsArray, $fields); |
||
| 242 | } |
||
| 243 | |||
| 244 | public function testHasUploadFieldsCreateForm() |
||
| 245 | { |
||
| 246 | $this->crudPanel->addField($this->uploadField, 'create'); |
||
| 247 | |||
| 248 | // TODO: update method documentation. the $form parameter does not default to 'both'. |
||
| 249 | $hasUploadFields = $this->crudPanel->hasUploadFields('create'); |
||
| 250 | |||
| 251 | $this->assertTrue($hasUploadFields); |
||
| 252 | } |
||
| 253 | |||
| 254 | public function testHasMultipleUploadFieldsCreateForm() |
||
| 255 | { |
||
| 256 | $this->crudPanel->addField($this->multipleUploadField, 'create'); |
||
| 257 | |||
| 258 | // TODO: update method documentation. the $form parameter does not default to 'both'. |
||
| 259 | $hasMultipleUploadFields = $this->crudPanel->hasUploadFields('create'); |
||
| 260 | |||
| 261 | $this->assertTrue($hasMultipleUploadFields); |
||
| 262 | } |
||
| 263 | |||
| 264 | public function testHasUploadFieldsUpdateForm() |
||
| 265 | { |
||
| 266 | $this->crudPanel->setModel(Article::class); |
||
| 267 | $this->crudPanel->addField($this->uploadField, 'update'); |
||
| 268 | |||
| 269 | // TODO: update method documentation. the $form parameter does not default to 'both'. |
||
| 270 | $hasUploadFields = $this->crudPanel->hasUploadFields('update', 1); |
||
| 271 | |||
| 272 | $this->assertTrue($hasUploadFields); |
||
| 273 | } |
||
| 274 | |||
| 275 | public function testEnableDetailsRow() |
||
| 276 | { |
||
| 277 | $this->crudPanel->setOperation('create'); |
||
| 278 | $this->crudPanel->enableDetailsRow(); |
||
| 279 | |||
| 280 | $this->assertTrue($this->crudPanel->getOperationSetting('detailsRow')); |
||
| 281 | } |
||
| 282 | |||
| 283 | public function testDisableDetailsRow() |
||
| 284 | { |
||
| 285 | $this->crudPanel->setOperation('list'); |
||
| 286 | $this->crudPanel->disableDetailsRow(); |
||
| 287 | |||
| 288 | $this->assertFalse($this->crudPanel->get('list.detailsRow')); |
||
| 289 | } |
||
| 290 | |||
| 291 | public function testSetDefaultPageLength() |
||
| 292 | { |
||
| 293 | $pageLength = 20; |
||
| 294 | $this->crudPanel->setDefaultPageLength($pageLength); |
||
| 295 | |||
| 296 | $this->assertEquals($pageLength, $this->crudPanel->getDefaultPageLength()); |
||
| 297 | } |
||
| 298 | |||
| 299 | public function testGetDefaultPageLength() |
||
| 300 | { |
||
| 301 | $defaultPageLength = $this->crudPanel->getDefaultPageLength(); |
||
| 302 | |||
| 303 | $this->assertEquals(25, $defaultPageLength); |
||
| 304 | } |
||
| 305 | |||
| 306 | public function testEnableExportButtons() |
||
| 307 | { |
||
| 308 | $this->crudPanel->enableExportButtons(); |
||
| 309 | |||
| 310 | $this->assertTrue($this->crudPanel->exportButtons()); |
||
| 311 | } |
||
| 312 | |||
| 313 | public function testGetExportButtons() |
||
| 314 | { |
||
| 315 | $exportButtons = $this->crudPanel->exportButtons(); |
||
| 316 | |||
| 317 | $this->assertFalse($exportButtons); |
||
| 318 | } |
||
| 319 | |||
| 320 | public function testGetRelatedEntriesAttributesFromBelongsToMany() |
||
| 321 | { |
||
| 322 | $this->crudPanel->setModel(User::class); |
||
| 323 | $this->crudPanel->setOperation('list'); |
||
| 324 | $user = $this->crudPanel->getModel()->where('id', 2)->first(); |
||
| 325 | $entries = $this->crudPanel->getRelatedEntriesAttributes($user, 'roles', 'name'); |
||
| 326 | $this->assertEquals([1 => 'admin', 2 => 'user'], $entries); |
||
| 327 | } |
||
| 328 | |||
| 329 | public function testGetRelatedEntriesAttributesFromBelongsToManyWithAcessor() |
||
| 330 | { |
||
| 331 | $this->crudPanel->setModel(User::class); |
||
| 332 | $this->crudPanel->setOperation('list'); |
||
| 333 | $user = $this->crudPanel->getModel()->where('id', 2)->first(); |
||
| 334 | $entries = $this->crudPanel->getRelatedEntriesAttributes($user, 'roles', 'role_name'); |
||
| 335 | $this->assertEquals([1 => 'admin++', 2 => 'user++'], $entries); |
||
| 336 | } |
||
| 337 | |||
| 338 | public function testGetRelatedEntriesAttributesFromHasMany() |
||
| 339 | { |
||
| 340 | $this->crudPanel->setModel(User::class); |
||
| 341 | $this->crudPanel->setOperation('list'); |
||
| 342 | $user = $this->crudPanel->getModel()->first(); |
||
| 343 | $entries = $this->crudPanel->getRelatedEntriesAttributes($user, 'articles', 'content'); |
||
| 344 | $this->assertCount(1, $entries); |
||
| 345 | } |
||
| 346 | |||
| 347 | public function testGetRelatedEntriesAttributesFromHasManyWithAcessor() |
||
| 348 | { |
||
| 349 | $this->crudPanel->setModel(User::class); |
||
| 350 | $this->crudPanel->setOperation('list'); |
||
| 351 | $user = $this->crudPanel->getModel()->first(); |
||
| 352 | $entries = $this->crudPanel->getRelatedEntriesAttributes($user, 'articles', 'content_composed'); |
||
| 353 | $this->assertCount(1, $entries); |
||
| 354 | } |
||
| 355 | |||
| 356 | public function testGetRelatedEntriesAttributesFromBelongsTo() |
||
| 357 | { |
||
| 358 | $this->crudPanel->setModel(Article::class); |
||
| 359 | $this->crudPanel->setOperation('list'); |
||
| 360 | $article = $this->crudPanel->getModel()->first(); |
||
| 361 | $entries = $this->crudPanel->getRelatedEntriesAttributes($article, 'user', 'name'); |
||
| 362 | $this->assertCount(1, $entries); |
||
| 363 | } |
||
| 364 | |||
| 365 | public function testGetRelatedEntriesAttributesFromBelongsToWithAcessor() |
||
| 366 | { |
||
| 367 | $this->crudPanel->setModel(Article::class); |
||
| 368 | $this->crudPanel->setOperation('list'); |
||
| 369 | $article = $this->crudPanel->getModel()->first(); |
||
| 370 | $entries = $this->crudPanel->getRelatedEntriesAttributes($article, 'user', 'name_composed'); |
||
| 371 | $this->assertCount(1, $entries); |
||
| 372 | } |
||
| 373 | |||
| 374 | public function testGetRelatedEntriesAttributesFromHasOne() |
||
| 375 | { |
||
| 376 | $this->crudPanel->setModel(User::class); |
||
| 377 | $this->crudPanel->setOperation('list'); |
||
| 378 | $user = $this->crudPanel->getModel()->first(); |
||
| 379 | $entries = $this->crudPanel->getRelatedEntriesAttributes($user, 'accountDetails', 'nickname'); |
||
| 380 | $this->assertCount(1, $entries); |
||
| 381 | } |
||
| 382 | |||
| 383 | public function testGetRelatedEntriesAttributesFromHasOneWithAcessor() |
||
| 384 | { |
||
| 385 | $this->crudPanel->setModel(User::class); |
||
| 386 | $this->crudPanel->setOperation('list'); |
||
| 387 | $user = $this->crudPanel->getModel()->first(); |
||
| 388 | $entries = $this->crudPanel->getRelatedEntriesAttributes($user, 'accountDetails', 'nickname_composed'); |
||
| 389 | $this->assertCount(1, $entries); |
||
| 390 | } |
||
| 391 | |||
| 392 | /** |
||
| 393 | * Tests define paginator length with single array [20, 30, 40]. |
||
| 394 | * |
||
| 395 | */ |
||
| 396 | public function testCrudPanelChangePaginatorLengthSingleArrayNoLabels() |
||
| 404 | } |
||
| 405 | |||
| 406 | /** |
||
| 407 | * Tests define paginator length with single array [20 => 'v', 30 => 't', 40 => 'q']. |
||
| 408 | * |
||
| 409 | */ |
||
| 410 | public function testCrudPanelChangePaginatorLengthSingleArrayWithLabels() |
||
| 411 | { |
||
| 412 | $this->crudPanel->setModel(User::class); |
||
| 413 | $this->crudPanel->setOperation('list'); |
||
| 414 | $this->crudPanel->setPageLengthMenu([20 => 'v', 30 => 't', 40 => 'q']); |
||
| 415 | $this->assertCount(2, $this->crudPanel->getOperationSetting('pageLengthMenu')); |
||
| 416 | $this->assertTrue(in_array(40, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
||
| 417 | $this->assertEquals($this->crudPanel->getOperationSetting('pageLengthMenu')[1], ['v', 't', 'q']); |
||
| 418 | } |
||
| 419 | |||
| 420 | /** |
||
| 421 | * Tests define paginator length with and 'all' options as -1 as defined in previous versions of BP |
||
| 422 | * |
||
| 423 | */ |
||
| 424 | public function testCrudPanelPaginatorWithAllAsOption() |
||
| 425 | { |
||
| 426 | $this->crudPanel->setModel(User::class); |
||
| 427 | $this->crudPanel->setOperation('list'); |
||
| 428 | $this->crudPanel->setPageLengthMenu([-1 => 'All']); |
||
| 429 | $this->assertCount(2, $this->crudPanel->getOperationSetting('pageLengthMenu')); |
||
| 430 | $this->assertTrue(in_array(-1, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
||
| 431 | |||
| 432 | $this->crudPanel->setPageLengthMenu([-1 , 1]); |
||
| 433 | $this->assertCount(2, $this->crudPanel->getOperationSetting('pageLengthMenu')); |
||
| 434 | $this->assertTrue(in_array(-1, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
||
| 435 | |||
| 436 | $this->crudPanel->setPageLengthMenu(-1); |
||
| 437 | $this->assertCount(2, $this->crudPanel->getOperationSetting('pageLengthMenu')); |
||
| 438 | $this->assertTrue(in_array(-1, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
||
| 439 | } |
||
| 440 | |||
| 441 | /** |
||
| 442 | * Tests if paginator aborts when 0 is provided as key. |
||
| 443 | * |
||
| 444 | */ |
||
| 445 | public function testCrudPanelPaginatorWithZeroAsOption() |
||
| 446 | { |
||
| 447 | $this->crudPanel->setModel(User::class); |
||
| 448 | $this->crudPanel->setOperation('list'); |
||
| 449 | |||
| 450 | try { |
||
| 451 | $this->crudPanel->setPageLengthMenu([0 => 'v', 30 => 't', 40 => 'q']); |
||
| 452 | } catch (\Throwable $a) { |
||
| 453 | } |
||
| 454 | |||
| 455 | $this->assertEquals(500, $a->getStatusCode()); |
||
| 456 | |||
| 457 | try { |
||
| 458 | $this->crudPanel->setPageLengthMenu([0, 1]); |
||
| 459 | } catch (\Throwable $b) { |
||
| 460 | } |
||
| 461 | |||
| 462 | $this->assertEquals(500, $b->getStatusCode()); |
||
| 463 | |||
| 464 | try { |
||
| 465 | $this->crudPanel->setPageLengthMenu(0); |
||
| 466 | } catch (\Throwable $c) { |
||
| 467 | } |
||
| 468 | |||
| 469 | $this->assertEquals(500, $c->getStatusCode()); |
||
| 470 | |||
| 471 | try { |
||
| 472 | $this->crudPanel->setPageLengthMenu([[0, 1]]); |
||
| 473 | } catch (\Throwable $d) { |
||
| 474 | } |
||
| 475 | |||
| 476 | $this->assertEquals(500, $d->getStatusCode()); |
||
| 477 | } |
||
| 478 | |||
| 479 | /** |
||
| 480 | * Tests define paginator length with multi array [[20, 30, 40],['v', 't', 'q']]. |
||
| 481 | * |
||
| 482 | */ |
||
| 483 | public function testCrudPanelChangePaginatorLengthMultiArrayWithLabels() |
||
| 484 | { |
||
| 485 | $this->crudPanel->setModel(User::class); |
||
| 486 | $this->crudPanel->setOperation('list'); |
||
| 487 | $this->crudPanel->setPageLengthMenu([[20, 30, 40], ['v', 't', 'q']]); |
||
| 488 | $this->assertCount(2, $this->crudPanel->getOperationSetting('pageLengthMenu')); |
||
| 489 | $this->assertTrue(in_array(40, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
||
| 490 | $this->assertEquals($this->crudPanel->getOperationSetting('pageLengthMenu')[1], ['v', 't', 'q']); |
||
| 491 | } |
||
| 492 | |||
| 493 | /** |
||
| 494 | * Tests define paginator length with multi array [[20, 30, 40]]. |
||
| 495 | * |
||
| 496 | */ |
||
| 497 | public function testCrudPanelChangePaginatorLengthMultiArrayNoLabels() |
||
| 498 | { |
||
| 499 | $this->crudPanel->setModel(User::class); |
||
| 500 | $this->crudPanel->setOperation('list'); |
||
| 501 | $this->crudPanel->setPageLengthMenu([[20, 30, 40]]); |
||
| 502 | $this->assertCount(2, $this->crudPanel->getOperationSetting('pageLengthMenu')); |
||
| 503 | $this->assertTrue(in_array(40, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
||
| 504 | $this->assertTrue(in_array(40, $this->crudPanel->getOperationSetting('pageLengthMenu')[1])); |
||
| 505 | } |
||
| 506 | |||
| 507 | /** |
||
| 508 | * Tests define paginator length with single value 40. |
||
| 509 | * |
||
| 510 | */ |
||
| 511 | public function testCrudPanelChangePaginatorLengthWithSingleValue() |
||
| 519 | } |
||
| 520 | |||
| 521 | /** |
||
| 522 | * Tests if table paginator adds default option non-existent at time in the paginator. |
||
| 523 | * |
||
| 524 | */ |
||
| 525 | public function testCrudPanelPaginatorAddsDefaultOptionNonExistent() |
||
| 526 | { |
||
| 527 | $this->crudPanel->setModel(User::class); |
||
| 528 | $this->crudPanel->setOperation('list'); |
||
| 529 | $this->crudPanel->setDefaultPageLength(40); |
||
| 530 | $this->crudPanel->setPageLengthMenu($this->defaultPaginator); |
||
| 531 | |||
| 532 | $this->assertCount(2, $this->crudPanel->getPageLengthMenu()); |
||
| 533 | $this->assertTrue(in_array(40, $this->crudPanel->getOperationSetting('pageLengthMenu')[0])); |
||
| 534 | $this->assertEquals(array_values($this->crudPanel->getPageLengthMenu()[0])[0], 40); |
||
| 535 | } |
||
| 536 | |||
| 537 | /** |
||
| 538 | * Tests if table paginator adds default option existent. |
||
| 539 | * |
||
| 540 | */ |
||
| 541 | public function testCrudPanelPaginatorAddsDefaultOptionExistent() |
||
| 551 | } |
||
| 552 | } |
||
| 553 |