Skip to content

Commit ca6e706

Browse files
committed
Test Fixes
1 parent 33a37e3 commit ca6e706

File tree

11 files changed

+61
-67
lines changed

11 files changed

+61
-67
lines changed

src/Traits/Configuration/ConfigurableAreasConfiguration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public function setConfigurableAreas(array $areas): self
2121
* Configure a specific Configurable Area
2222
*
2323
* @param string $configurableArea
24-
* @param array<mixed> $config
24+
* @param string|array<mixed> $config
2525
* @return self
2626
*/
27-
public function setConfigurableArea(string $configurableArea, array $config): self
27+
public function setConfigurableArea(string $configurableArea, string|array $config = []): self
2828
{
2929
if (array_key_exists($configurableArea, $this->configurableAreas)) {
3030
$this->configurableAreas[$configurableArea] = $config;

tests/Unit/DataTransferObjects/DebuggableDataTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ public function test_check_all_default_dto_elements()
2525

2626
$defaultQuery = 'select "pets"."id" as "id", "pets"."sort" as "sort", "pets"."name" as "name", "pets"."age" as "age", "breed"."name" as "breed.name", "pets"."last_visit" as "last_visit" from "pets" left join "breeds" as "breed" on "pets"."breed_id" = "breed"."id" limit 10 offset 0';
2727
$this->assertSame($debuggableArray['query'], $defaultQuery);
28-
$this->assertSame($debuggableArray['filters'], ['breed' => [],
29-
'species' => [],
30-
'breed_id_filter' => null,
31-
'pet_name_filter' => null,
32-
'last_visit_date_filter' => null,
33-
'last_visit_datetime_filter' => null,
34-
'breed_select_filter' => null]);
28+
$this->assertSame($debuggableArray['filters'], []);
3529
$this->assertSame($debuggableArray['sorts'], []);
3630
$this->assertSame($debuggableArray['search'], '');
3731
$this->assertFalse($debuggableArray['select-all']);

tests/Unit/Traits/Configuration/ComponentConfigurationTest.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ final class ComponentConfigurationTest extends TestCase
1111
{
1212
public function test_initial_wrapper_attributes_get_set(): void
1313
{
14-
$this->assertSame(['id' => 'datatable-'.$this->basicTable->getId()], $this->basicTable->getComponentWrapperAttributes());
14+
$this->assertSame(['id' => 'datatable-'.$this->basicTable->getId(), 'wire:key' => 'table-wrapper'], $this->basicTable->getComponentWrapperAttributes());
1515

1616
$this->basicTable->setComponentWrapperAttributes(['this' => 'that']);
1717

18-
$this->assertSame($this->basicTable->getComponentWrapperAttributes(), ['this' => 'that']);
18+
$this->assertSame($this->basicTable->getComponentWrapperAttributes(), ['id' => 'datatable-'.$this->basicTable->getId(), 'wire:key' => 'table-wrapper', 'this' => 'that']);
1919
}
2020

2121
public function test_can_set_table_wrapper_attributes(): void
@@ -172,6 +172,7 @@ public function test_can_set_default_sorting_labels(): void
172172
$this->assertSame('2-1', $this->basicTable->getDefaultSortingLabelDesc());
173173
}
174174

175+
/* RETIRED
175176
public function test_can_set_query_string_status(): void
176177
{
177178
$this->assertTrue($this->basicTable->getQueryStringStatus());
@@ -191,7 +192,7 @@ public function test_can_set_query_string_status(): void
191192
$this->basicTable->setQueryStringEnabled();
192193
193194
$this->assertTrue($this->basicTable->getQueryStringStatus());
194-
}
195+
}*/
195196

196197
public function test_can_set_eager_load_relations_status(): void
197198
{
@@ -398,19 +399,19 @@ public function test_can_add_extra_with_avg(): void
398399

399400
public function test_can_set_collapsing_column_button_collapse_attributes(): void
400401
{
401-
$this->assertSame(['class' => 'text-yellow-600 h-6 w-6', 'default-styling' => true, 'default-colors' => true], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
402+
$this->assertSame(['default-styling' => true, 'default-colors' => true], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
402403

403404
$this->basicTable->setCollapsingColumnButtonCollapseAttributes(['class' => 'text-blue-500']);
404-
$this->assertSame(['default-styling' => false, 'default-colors' => false, 'class' => 'text-blue-500'], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
405+
$this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => 'text-blue-500'], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
405406

406-
$this->basicTable->setCollapsingColumnButtonCollapseAttributes(['class' => 'text-blue-500', 'default-styling' => true]);
407-
$this->assertSame(['default-styling' => true, 'default-colors' => false, 'class' => 'text-blue-500'], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
407+
$this->basicTable->setCollapsingColumnButtonCollapseAttributes(['class' => 'text-blue-500', 'default-styling' => false]);
408+
$this->assertSame(['default-styling' => false, 'default-colors' => true, 'class' => 'text-blue-500'], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
408409

409-
$this->basicTable->setCollapsingColumnButtonCollapseAttributes(['class' => 'text-red-500', 'default-colors' => true]);
410-
$this->assertSame(['default-styling' => false, 'default-colors' => true, 'class' => 'text-red-500'], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
410+
$this->basicTable->setCollapsingColumnButtonCollapseAttributes(['class' => 'text-red-500', 'default-styling' => true, 'default-colors' => false]);
411+
$this->assertSame(['default-styling' => true, 'default-colors' => false, 'class' => 'text-red-500'], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
411412

412-
$this->basicTable->setCollapsingColumnButtonCollapseAttributes(['default-styling' => true, 'class' => 'text-green-500', 'default-colors' => true]);
413-
$this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => 'text-green-500'], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
413+
$this->basicTable->setCollapsingColumnButtonCollapseAttributes(['default-styling' => false, 'class' => 'text-green-500', 'default-colors' => false]);
414+
$this->assertSame(['default-styling' => false, 'default-colors' => false, 'class' => 'text-green-500'], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
414415

415416
$this->assertSame(['default-styling' => true, 'default-colors' => true], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
416417
}
@@ -420,17 +421,20 @@ public function test_can_set_collapsing_column_button_expand_attributes(): void
420421
$this->assertSame(['default-styling' => true, 'default-colors' => true], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
421422

422423
$this->basicTable->setCollapsingColumnButtonExpandAttributes(['class' => 'text-blue-500']);
423-
$this->assertSame(['default-styling' => false, 'default-colors' => false, 'class' => 'text-blue-500'], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
424+
$this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => 'text-blue-500'], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
424425

425-
$this->basicTable->setCollapsingColumnButtonExpandAttributes(['class' => 'text-blue-500', 'default-styling' => true]);
426-
$this->assertSame(['default-styling' => true, 'default-colors' => false, 'class' => 'text-blue-500'], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
426+
$this->basicTable->setCollapsingColumnButtonExpandAttributes(['class' => 'text-blue-500', 'default-styling' => false]);
427+
$this->assertSame(['default-styling' => false, 'default-colors' => true, 'class' => 'text-blue-500'], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
427428

428-
$this->basicTable->setCollapsingColumnButtonExpandAttributes(['class' => 'text-red-500', 'default-colors' => true]);
429-
$this->assertSame(['default-styling' => false, 'default-colors' => true, 'class' => 'text-red-500'], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
429+
$this->basicTable->setCollapsingColumnButtonExpandAttributes(['class' => 'text-red-500', 'default-colors' => false]);
430+
$this->assertSame(['default-styling' => true, 'default-colors' => false, 'class' => 'text-red-500'], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
430431

431432
$this->basicTable->setCollapsingColumnButtonExpandAttributes(['default-styling' => true, 'class' => 'text-green-500', 'default-colors' => true]);
432433
$this->assertSame(['default-styling' => true, 'default-colors' => true, 'class' => 'text-green-500'], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
433434

435+
$this->basicTable->setCollapsingColumnButtonExpandAttributes(['default-styling' => false, 'class' => 'text-green-500', 'default-colors' => false]);
436+
$this->assertSame(['default-styling' => false, 'default-colors' => false, 'class' => 'text-green-500'], $this->basicTable->getCollapsingColumnButtonExpandAttributes());
437+
434438
$this->assertSame(['default-styling' => true, 'default-colors' => true], $this->basicTable->getCollapsingColumnButtonCollapseAttributes());
435439

436440
}

tests/Unit/Traits/Helpers/BulkActionsHelpersTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function test_select_clears_by_default_when_filtering(): void
233233
$this->assertSame([1, 2, 3, 4, 5], $this->basicTable->getSelected());
234234

235235
$this->basicTable->setFilter('breed_id_filter', '2');
236-
$this->basicTable->updatedappliedFilters('2', 'breed_id_filter');
236+
$this->basicTable->updatedTestAppliedFilters('2', 'breed_id_filter');
237237

238238
$this->assertSame([], $this->basicTable->getSelected());
239239
}
@@ -244,7 +244,7 @@ public function test_select_does_clear_when_filtering_when_enabled(): void
244244
$this->assertSame([1, 2, 3, 4, 5], $this->basicTable->getSelected());
245245
$this->basicTable->setClearSelectedOnFilterEnabled();
246246
$this->basicTable->setFilter('breed_id_filter', '2');
247-
$this->basicTable->updatedappliedFilters('2', 'breed_id_filter');
247+
$this->basicTable->updatedTestAppliedFilters('2', 'breed_id_filter');
248248
$this->assertSame([], $this->basicTable->getSelected());
249249
}
250250

@@ -254,7 +254,7 @@ public function test_select_does_not_clear_when_filtering_when_disabled(): void
254254
$this->assertSame([1, 2, 3, 4, 5], $this->basicTable->getSelected());
255255
$this->basicTable->setClearSelectedOnFilterDisabled();
256256
$this->basicTable->setFilter('breed_id_filter', '2');
257-
$this->basicTable->updatedappliedFilters('2', 'breed_id_filter');
257+
$this->basicTable->updatedTestAppliedFilters('2', 'breed_id_filter');
258258
$this->assertSame([1, 2, 3, 4, 5], $this->basicTable->getSelected());
259259
}
260260
}

tests/Unit/Traits/Helpers/ColumnHelpersTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ public function test_can_get_searchable_columns(): void
7777
->map(fn (Column $column) => $column->getColumnSelectName())
7878
->toArray();
7979

80-
$this->assertSame(['name', 'breed.name'], $selectable);
80+
ksort($selectable);
81+
82+
$default = ['name','breed.name'];
83+
ksort($default);
84+
85+
$this->assertSame(array_values($default), array_values($selectable));
8186
}
8287

8388
public function test_can_get_a_list_of_column_relations(): void

tests/Unit/Traits/Helpers/ComponentHelpersTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function test_can_get_default_sorting_labels(): void
4646
$this->assertSame('Z-A', $this->basicTable->getDefaultSortingLabelDesc());
4747
}
4848

49+
/* RETIRED
4950
public function test_can_get_query_string_status(): void
5051
{
5152
$this->assertTrue($this->basicTable->getQueryStringStatus());
@@ -57,7 +58,7 @@ public function test_can_get_query_string_status(): void
5758
$this->assertTrue($this->basicTable->queryStringIsDisabled());
5859
5960
$this->assertFalse($this->basicTable->getQueryStringStatus());
60-
}
61+
}*/
6162

6263
public function test_can_get_table_name(): void
6364
{
@@ -187,8 +188,9 @@ public function test_can_add_additional_selects_nonarray(): void
187188
// $this->assertSame($this->defaultFingerPrintingAlgo($this->basicTable::class), $this->basicTable->getDataTableFingerprint());
188189
// }
189190

191+
/* RETIRED
190192
public function test_can_get_query_string_alias_and_it_will_be_the_same_as_table_name_by_default(): void
191193
{
192194
$this->assertSame($this->basicTable->getTableName(), $this->basicTable->getQueryStringAlias());
193-
}
195+
}*/
194196
}

tests/Unit/Traits/Helpers/FilterHelpersTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function test_can_set_filter_value(): void
111111

112112
$this->basicTable->setFilter('breed_id_filter', 2);
113113

114-
$this->assertSame('2', $this->basicTable->getAppliedFilterWithValue('breed_id_filter'));
114+
$this->assertSame(2, $this->basicTable->getAppliedFilterWithValue('breed_id_filter'));
115115

116116
$this->basicTable->setFilter('pet_name_filter', 'Test');
117117

@@ -246,14 +246,14 @@ public function configure(): void
246246
$testTable->bootAll();
247247

248248
$testTable->setFilter('breed_id_filter', '2');
249-
$testTable->updatedappliedFilters('2', 'breed_id_filter');
249+
$testTable->updatedTestAppliedFilters('2', 'breed_id_filter');
250250
$this->assertSame(['breed_id_filter' => '2'], $testTable->getAppliedFiltersWithValues());
251251
Event::assertNotDispatched(FilterApplied::class);
252252

253253
$testTable->enableFilterAppliedEvent();
254254

255255
$testTable->setFilter('breed_id_filter', '3');
256-
$testTable->updatedappliedFilters('3', 'breed_id_filter');
256+
$testTable->updatedTestAppliedFilters('3', 'breed_id_filter');
257257
$this->assertSame(['breed_id_filter' => '3'], $testTable->getAppliedFiltersWithValues());
258258
Event::assertDispatched(FilterApplied::class);
259259

tests/Unit/Traits/Helpers/QueryStringHelpersTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public function getCurrentQueryStringBinding(): array
5353

5454
}
5555

56-
public function test_check_querystring_alias_returns_default_if_enabled(): void
56+
// Retired - as now specific per-feature
57+
/* public function test_check_querystring_alias_returns_default_if_enabled(): void
5758
{
5859
5960
$testTableQueryString = new class extends PetsTable
@@ -82,5 +83,5 @@ public function getCurrentQueryStringBinding(): array
8283
$this->assertSame('test123', $testTableQueryString->getQueryStringAlias());
8384
$this->assertSame(['table' => ['except' => null, 'history' => false, 'keep' => false, 'as' => 'test123']], $testTableQueryString->getCurrentQueryStringBinding());
8485
85-
}
86+
}*/
8687
}

tests/Unit/Traits/Helpers/SessionStorageHelpersTest.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ public function test_can_store_for_fikers(): void
3838
$this->assertSame(['1'], $this->basicTable->getAppliedFilterWithValue('breed'));
3939
$this->assertSame([
4040
'breed' => ['1'],
41-
'species' => [],
42-
'breed_id_filter' => null,
43-
'pet_name_filter' => null,
44-
'last_visit_date_filter' => null,
45-
'last_visit_datetime_filter' => null,
46-
'breed_select_filter' => null,
4741
], $this->basicTable->appliedFilters);
4842
$this->assertSame(['breed' => ['1'],
4943
'species' => [],
@@ -54,13 +48,7 @@ public function test_can_store_for_fikers(): void
5448
'breed_select_filter' => null], $this->basicTable->getStoredFilterValues());
5549

5650
$this->basicTable->setFilter('breed', ['2']);
57-
$this->assertSame(['breed' => ['2'],
58-
'species' => [],
59-
'breed_id_filter' => null,
60-
'pet_name_filter' => null,
61-
'last_visit_date_filter' => null,
62-
'last_visit_datetime_filter' => null,
63-
'breed_select_filter' => null], $this->basicTable->appliedFilters);
51+
$this->assertSame(['breed' => ['2']], $this->basicTable->appliedFilters);
6452
$this->assertSame(['2'], $this->basicTable->getAppliedFilterWithValue('breed'));
6553
$this->assertSame(['breed' => ['2']], $this->basicTable->getStoredFilterValues());
6654

tests/Unit/Views/Filters/BooleanFilterTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,27 +134,27 @@ public function test_can_set_custom_input_attributes_boolean(): void
134134
'class' => 'bg-red-500',
135135
]);
136136

137-
$this->assertFalse(self::$filterInstance->getInputAttributesBag()['default-styling']);
138-
$this->assertFalse(self::$filterInstance->getInputAttributesBag()['default-colors']);
137+
$this->assertTrue(self::$filterInstance->getInputAttributesBag()['default-styling']);
138+
$this->assertTrue(self::$filterInstance->getInputAttributesBag()['default-colors']);
139139
$this->assertSame('bg-red-500', self::$filterInstance->getInputAttributesBag()['class']);
140140
self::$filterInstance->setInputAttributes([
141141
'class' => 'bg-red-500 dark:bg-red-500',
142-
'default-styling' => true,
142+
'default-styling' => false,
143143
]);
144144
$currentAttributeBag = self::$filterInstance->getInputAttributesBag()->getAttributes();
145145
ksort($currentAttributeBag);
146146

147-
$this->assertTrue($currentAttributeBag['default-styling']);
148-
$this->assertFalse($currentAttributeBag['default-colors']);
147+
$this->assertFalse($currentAttributeBag['default-styling']);
148+
$this->assertTrue($currentAttributeBag['default-colors']);
149149
$this->assertSame('bg-red-500 dark:bg-red-500', $currentAttributeBag['class']);
150150

151151
$this->assertSame([
152152
'@click' => 'toggleStatusWithUpdate',
153153
'activeColor' => 'bg-blue-600',
154154
'blobColor' => 'bg-white',
155155
'class' => 'bg-red-500 dark:bg-red-500',
156-
'default-colors' => false,
157-
'default-styling' => true,
156+
'default-colors' => true,
157+
'default-styling' => false,
158158
'id' => $baseAttributes['id'],
159159
'inactiveColor' => 'bg-neutral-200',
160160
'type' => 'button',
@@ -164,8 +164,8 @@ public function test_can_set_custom_input_attributes_boolean(): void
164164
self::$filterInstance->setInputAttributes([
165165
'activeColor' => 'bg-red-600',
166166
'blobColor' => 'bg-green-500',
167-
'default-colors' => false,
168-
'default-styling' => true,
167+
'default-colors' => true,
168+
'default-styling' => false,
169169
'inactiveColor' => 'bg-blue-200',
170170
]);
171171
$currentAttributeBag = self::$filterInstance->getInputAttributesBag()->getAttributes();
@@ -175,8 +175,8 @@ public function test_can_set_custom_input_attributes_boolean(): void
175175
'@click' => 'toggleStatusWithUpdate',
176176
'activeColor' => 'bg-red-600',
177177
'blobColor' => 'bg-green-500',
178-
'default-colors' => false,
179-
'default-styling' => true,
178+
'default-colors' => true,
179+
'default-styling' => false,
180180
'id' => $baseAttributes['id'],
181181
'inactiveColor' => 'bg-blue-200',
182182
'type' => 'button',

0 commit comments

Comments
 (0)