Skip to content

Commit ae28d03

Browse files
authored
Add Missing Tools Tests (rappasoft#2086)
* Add Missing Tests * Fix styling * Update Test Names * test_filter_array_setup --------- Co-authored-by: lrljoe <[email protected]>
1 parent b1a8b79 commit ae28d03

File tree

8 files changed

+65
-40
lines changed

8 files changed

+65
-40
lines changed

tests/Unit/Features/AutoInjectRappasoftAssetsTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
final class AutoInjectRappasoftAssetsTest extends TestCase
99
{
10-
public function test_shouldInjectRappasoftAndThirdParty()
10+
public function test_should_inject_rappasoft_and_third_party()
1111
{
1212
config()->set('livewire-tables.inject_core_assets_enabled', true);
1313
config()->set('livewire-tables.inject_third_party_assets_enabled', true);
@@ -20,7 +20,7 @@ public function test_shouldInjectRappasoftAndThirdParty()
2020
$this->assertStringContainsStringIgnoringCase('<script src="/rappasoft/laravel-livewire-tables/thirdparty.min.js" ></script>', $injectionReturn);
2121
}
2222

23-
public function test_shouldNotInjectRappasoftOrThirdParty()
23+
public function test_should_not_inject_rappasoft_or_third_party()
2424
{
2525
config()->set('livewire-tables.inject_core_assets_enabled', false);
2626
config()->set('livewire-tables.inject_third_party_assets_enabled', false);
@@ -30,7 +30,7 @@ public function test_shouldNotInjectRappasoftOrThirdParty()
3030
$this->assertEquals('<html><head> </head><body></body></html>', AutoInjectRappasoftAssets::injectAssets('<html><head></head><body></body></html>'));
3131
}
3232

33-
public function test_shouldOnlyInjectThirdParty()
33+
public function test_should_only_inject_third_party()
3434
{
3535
config()->set('livewire-tables.inject_core_assets_enabled', false);
3636
config()->set('livewire-tables.inject_third_party_assets_enabled', true);
@@ -41,7 +41,7 @@ public function test_shouldOnlyInjectThirdParty()
4141
$this->assertStringContainsStringIgnoringCase('<script src="/rappasoft/laravel-livewire-tables/thirdparty.min.js" ></script>', $injectionReturn);
4242
}
4343

44-
public function test_shouldOnlyInjectRappasoft()
44+
public function test_should_only_inject_rappasoft()
4545
{
4646
config()->set('livewire-tables.inject_core_assets_enabled', true);
4747
config()->set('livewire-tables.inject_third_party_assets_enabled', false);

tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class RappasoftFrontendAssetsTest extends TestCase
1010
{
11-
public function test_JsResponseSetupCacheEnabled(): array
11+
public function test_js_response_setup_cache_enabled(): array
1212
{
1313
config()->set('livewire-tables.cache_assets', true);
1414
$lastModified = \Carbon\Carbon::now()->timestamp;
@@ -22,7 +22,7 @@ public function test_JsResponseSetupCacheEnabled(): array
2222
return ['lastModified' => $lastModified, 'responseHeaders' => $response->headers->all()];
2323
}
2424

25-
public function test_JsResponseSetupCacheDisabled(): array
25+
public function test_js_response_setup_cache_disabled(): array
2626
{
2727
config()->set('livewire-tables.cache_assets', false);
2828
$date = date_create();
@@ -36,7 +36,7 @@ public function test_JsResponseSetupCacheDisabled(): array
3636
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
3737
}
3838

39-
public function test_CssResponseSetupCacheEnabled(): array
39+
public function test_css_response_setup_cache_enabled(): array
4040
{
4141
config()->set('livewire-tables.cache_assets', true);
4242
$date = date_create();
@@ -50,7 +50,7 @@ public function test_CssResponseSetupCacheEnabled(): array
5050
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
5151
}
5252

53-
public function test_CssResponseSetupCacheDisabled(): array
53+
public function test_css_response_setup_cache_disabled(): array
5454
{
5555
config()->set('livewire-tables.cache_assets', false);
5656

@@ -66,7 +66,7 @@ public function test_CssResponseSetupCacheDisabled(): array
6666
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
6767
}
6868

69-
public function test_ThirdPartyCssResponseSetupCacheEnabled(): array
69+
public function test_third_party_css_response_setup_cache_enabled(): array
7070
{
7171
config()->set('livewire-tables.cache_assets', true);
7272

@@ -82,7 +82,7 @@ public function test_ThirdPartyCssResponseSetupCacheEnabled(): array
8282
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
8383
}
8484

85-
public function test_ThirdPartyCssResponseSetupCacheDisabled(): array
85+
public function test_third_party_css_response_setup_cache_disabled(): array
8686
{
8787
config()->set('livewire-tables.cache_assets', false);
8888

@@ -98,7 +98,7 @@ public function test_ThirdPartyCssResponseSetupCacheDisabled(): array
9898
return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()];
9999
}
100100

101-
public function test_ThirdPartyJsResponseSetupCacheEnabled(): array
101+
public function test_third_party_js_response_setup_cache_enabled(): array
102102
{
103103
config()->set('livewire-tables.cache_assets', true);
104104
$lastModified = \Carbon\Carbon::now()->timestamp;
@@ -112,7 +112,7 @@ public function test_ThirdPartyJsResponseSetupCacheEnabled(): array
112112
return ['lastModified' => $lastModified, 'responseHeaders' => $response->headers->all()];
113113
}
114114

115-
public function test_ThirdPartyJsResponseSetupCacheDisabled(): array
115+
public function test_third_party_js_response_setup_cache_disabled(): array
116116
{
117117
config()->set('livewire-tables.cache_assets', false);
118118
$date = date_create();
@@ -148,7 +148,7 @@ public function test_scripts()
148148
$this->assertTrue($assets->hasRenderedRappsoftTableScripts);
149149
}
150150

151-
public function test_thirdPartystyles()
151+
public function test_third_partystyles()
152152
{
153153
$assets = app(RappasoftFrontendAssets::class);
154154

@@ -159,7 +159,7 @@ public function test_thirdPartystyles()
159159
$this->assertTrue($assets->hasRenderedRappsoftTableThirdPartyStyles);
160160
}
161161

162-
public function test_thirdPartyscripts()
162+
public function test_third_partyscripts()
163163
{
164164
$assets = app(RappasoftFrontendAssets::class);
165165

@@ -170,97 +170,97 @@ public function test_thirdPartyscripts()
170170
$this->assertTrue($assets->hasRenderedRappsoftTableThirdPartyScripts);
171171
}
172172

173-
#[Depends('test_JsResponseSetupCacheEnabled')]
173+
#[Depends('test_js_response_setup_cache_enabled')]
174174
public function test_check_pretend_response_is_js_returns_correct_cache_control_cache_enabled(array $jsResponseSetupCacheEnabled)
175175
{
176176
$this->assertSame('max-age=86400, public', $jsResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]);
177177
}
178178

179-
#[Depends('test_JsResponseSetupCacheEnabled')]
179+
#[Depends('test_js_response_setup_cache_enabled')]
180180
public function test_check_pretend_response_is_js_returns_correct_content_type_cache_enabled(array $jsResponseSetupCacheEnabled)
181181
{
182182
$this->assertSame('application/javascript; charset=utf-8', $jsResponseSetupCacheEnabled['responseHeaders']['content-type'][0]);
183183
}
184184

185-
#[Depends('test_JsResponseSetupCacheDisabled')]
185+
#[Depends('test_js_response_setup_cache_disabled')]
186186
public function test_check_pretend_response_is_js_returns_correct_cache_control_cache_disabled(array $jsResponseSetupCacheDisabled)
187187
{
188188
$this->assertSame('max-age=1, public', $jsResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]);
189189
}
190190

191-
#[Depends('test_JsResponseSetupCacheDisabled')]
191+
#[Depends('test_js_response_setup_cache_disabled')]
192192
public function test_check_pretend_response_is_js_returns_correct_content_type_cache_disabled(array $jsResponseSetupCacheDisabled)
193193
{
194194
$this->assertSame('application/javascript; charset=utf-8', $jsResponseSetupCacheDisabled['responseHeaders']['content-type'][0]);
195195
}
196196

197-
#[Depends('test_CssResponseSetupCacheEnabled')]
197+
#[Depends('test_css_response_setup_cache_enabled')]
198198
public function test_check_pretend_response_is_css_returns_correct_cache_control_caching_enabled(array $cssResponseSetupCacheEnabled)
199199
{
200200
$this->assertSame('max-age=86400, public', $cssResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]);
201201
}
202202

203-
#[Depends('test_CssResponseSetupCacheEnabled')]
203+
#[Depends('test_css_response_setup_cache_enabled')]
204204
public function test_check_pretend_response_is_css_returns_correct_content_type_caching_enabled(array $cssResponseSetupCacheEnabled)
205205
{
206206
$this->assertSame('text/css; charset=utf-8', $cssResponseSetupCacheEnabled['responseHeaders']['content-type'][0]);
207207
}
208208

209-
#[Depends('test_CssResponseSetupCacheDisabled')]
209+
#[Depends('test_css_response_setup_cache_disabled')]
210210
public function test_check_pretend_response_is_css_returns_correct_cache_control_caching_disabled(array $cssResponseSetupCacheDisabled)
211211
{
212212
$this->assertSame('max-age=1, public', $cssResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]);
213213
}
214214

215-
#[Depends('test_CssResponseSetupCacheDisabled')]
215+
#[Depends('test_css_response_setup_cache_disabled')]
216216
public function test_check_pretend_response_is_css_returns_correct_content_type_caching_disabled(array $cssResponseSetupCacheDisabled)
217217
{
218218
$this->assertSame('text/css; charset=utf-8', $cssResponseSetupCacheDisabled['responseHeaders']['content-type'][0]);
219219
}
220220

221-
#[Depends('test_ThirdPartyCssResponseSetupCacheEnabled')]
221+
#[Depends('test_third_party_css_response_setup_cache_enabled')]
222222
public function test_tp_check_pretend_response_is_css_returns_correct_cache_control_caching_enabled(array $thirdPartyCssResponseSetupCacheEnabled)
223223
{
224224
$this->assertSame('max-age=86400, public', $thirdPartyCssResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]);
225225
}
226226

227-
#[Depends('test_ThirdPartyCssResponseSetupCacheEnabled')]
227+
#[Depends('test_third_party_css_response_setup_cache_enabled')]
228228
public function test_tp_check_pretend_response_is_css_returns_correct_content_type_caching_enabled(array $thirdPartyCssResponseSetupCacheEnabled)
229229
{
230230
$this->assertSame('text/css; charset=utf-8', $thirdPartyCssResponseSetupCacheEnabled['responseHeaders']['content-type'][0]);
231231
}
232232

233-
#[Depends('test_ThirdPartyCssResponseSetupCacheDisabled')]
233+
#[Depends('test_third_party_css_response_setup_cache_disabled')]
234234
public function test_tp_check_pretend_response_is_css_returns_correct_cache_control_caching_disabled(array $thirdPartyCssResponseSetupCacheDisabled)
235235
{
236236
$this->assertSame('max-age=1, public', $thirdPartyCssResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]);
237237
}
238238

239-
#[Depends('test_ThirdPartyCssResponseSetupCacheDisabled')]
239+
#[Depends('test_third_party_css_response_setup_cache_disabled')]
240240
public function test_tp_check_pretend_response_is_css_returns_correct_content_type_caching_disabled(array $thirdPartyCssResponseSetupCacheDisabled)
241241
{
242242
$this->assertSame('text/css; charset=utf-8', $thirdPartyCssResponseSetupCacheDisabled['responseHeaders']['content-type'][0]);
243243
}
244244

245-
#[Depends('test_ThirdPartyJsResponseSetupCacheEnabled')]
245+
#[Depends('test_third_party_js_response_setup_cache_enabled')]
246246
public function test_tp_check_pretend_response_is_js_returns_correct_cache_control_cache_enabled(array $thirdPartyJsResponseSetupCacheEnabled)
247247
{
248248
$this->assertSame('max-age=86400, public', $thirdPartyJsResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]);
249249
}
250250

251-
#[Depends('test_ThirdPartyJsResponseSetupCacheEnabled')]
251+
#[Depends('test_third_party_js_response_setup_cache_enabled')]
252252
public function test_tp_check_pretend_response_is_js_returns_correct_content_type_cache_enabled(array $thirdPartyJsResponseSetupCacheEnabled)
253253
{
254254
$this->assertSame('application/javascript; charset=utf-8', $thirdPartyJsResponseSetupCacheEnabled['responseHeaders']['content-type'][0]);
255255
}
256256

257-
#[Depends('test_ThirdPartyJsResponseSetupCacheDisabled')]
257+
#[Depends('test_third_party_js_response_setup_cache_disabled')]
258258
public function test_tp_check_pretend_response_is_js_returns_correct_cache_control_cache_disabled(array $thirdPartyJsResponseSetupCacheDisabled)
259259
{
260260
$this->assertSame('max-age=1, public', $thirdPartyJsResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]);
261261
}
262262

263-
#[Depends('test_ThirdPartyJsResponseSetupCacheDisabled')]
263+
#[Depends('test_third_party_js_response_setup_cache_disabled')]
264264
public function test_tp_check_pretend_response_is_js_returns_correct_content_type_cache_disabled(array $thirdPartyJsResponseSetupCacheDisabled)
265265
{
266266
$this->assertSame('application/javascript; charset=utf-8', $thirdPartyJsResponseSetupCacheDisabled['responseHeaders']['content-type'][0]);

tests/Unit/Traits/Configuration/ColumnSelectConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function test_variables_are_correct_types(): void
1212
$this->assertIsArray($this->basicTable->selectedColumns);
1313
}
1414

15-
public function test_check_protected_fields_columnSelectStatus(): void
15+
public function test_check_protected_fields_column_select_status(): void
1616
{
1717
$this->expectException(\Livewire\Exceptions\PropertyNotFoundException::class);
1818
$this->assertIsBool($this->basicTable->columnSelectStatus);

tests/Unit/Traits/Helpers/ToolsHelpersTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,29 @@ public function test_can_get_tools_display(): void
111111
$this->assertFalse($this->basicTable->shouldShowTools());
112112

113113
}
114+
115+
public function test_can_get_tools_status_no_sortpills(): void
116+
{
117+
$this->assertTrue($this->basicTable->shouldShowTools());
118+
119+
$this->basicTable->setToolsEnabled();
120+
$this->basicTable->setSortingDisabled();
121+
$this->basicTable->setToolBarDisabled();
122+
$this->assertFalse($this->basicTable->shouldShowTools());
123+
124+
$this->basicTable->setFiltersEnabled();
125+
$this->basicTable->setFilter('pet_name_filter', 'Test');
126+
127+
$this->assertTrue($this->basicTable->shouldShowTools());
128+
129+
}
130+
131+
public function test_can_get_tools_status_toolbar_disabled(): void
132+
{
133+
$this->assertTrue($this->basicTable->shouldShowTools());
134+
$this->basicTable->setToolsEnabled();
135+
$this->basicTable->setToolBarDisabled();
136+
$this->assertFalse($this->basicTable->shouldShowToolBar());
137+
138+
}
114139
}

tests/Unit/Traits/Visuals/FilterVisualsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ public function test_filter_pills_show_when_enabled(): void
4949
->assertSee('Applied Filters');
5050
}
5151

52-
public function test_event_dispatched_when_filterComponents_set(): void
52+
public function test_event_dispatched_when_filter_components_set(): void
5353
{
5454
Livewire::test(PetsTable::class)
5555
->set('filterComponents.breed', [1])
5656
->assertDispatched('filter-was-set');
5757
}
5858

59-
public function test_event_dispatched_when_setFilter_dispatched(): void
59+
public function test_event_dispatched_when_set_filter_dispatched(): void
6060
{
6161
Livewire::test(PetsTable::class)
6262
->dispatch('setFilter', filterKey: 'breed', value: [1])

tests/Unit/Traits/Visuals/ReorderingVisualsTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final class ReorderingVisualsTest extends TestCase
1111
{
12-
public function test_FilterArraySetup(): array
12+
public function test_filter_array_setup(): array
1313
{
1414
$filterDefaultArray = ['breed' => [], 'species' => [], 'breed_id_filter' => null, 'pet_name_filter' => null, 'last_visit_date_filter' => null, 'last_visit_datetime_filter' => null, 'breed_select_filter' => null];
1515
$this->assertNotEmpty($filterDefaultArray);
@@ -95,7 +95,7 @@ public function test_sorting_pills_hide_on_reorder(): void
9595
->assertSeeHtml('wire:key="table-sorting-pill-id"');
9696
}
9797

98-
#[Depends('test_FilterArraySetup')]
98+
#[Depends('test_filter_array_setup')]
9999
public function test_sorting_is_disabled_on_reorder(array $filterDefaultArray): void
100100
{
101101
Livewire::test(PetsTable::class)
@@ -169,7 +169,7 @@ public function test_per_page_gets_set_on_reorder(): void
169169
->assertSet('perPage', 10);
170170
}
171171

172-
#[Depends('test_FilterArraySetup')]
172+
#[Depends('test_filter_array_setup')]
173173
public function test_search_hides_on_reorder(array $filterDefaultArray): void
174174
{
175175
Livewire::test(PetsTable::class)
@@ -267,7 +267,7 @@ public function test_bulk_actions_row_select_some_gets_hidden_on_reorder(): void
267267
->assertDontSee('do you want to select all');
268268
}
269269

270-
#[Depends('test_FilterArraySetup')]
270+
#[Depends('test_filter_array_setup')]
271271
public function test_filters_are_disabled_on_reorder(array $filterDefaultArray): void
272272
{
273273
$customisedFilterArray = $filterDefaultArray;
@@ -290,7 +290,7 @@ public function test_filters_are_disabled_on_reorder(array $filterDefaultArray):
290290
->assertSeeHtml('Filters');
291291
}
292292

293-
#[Depends('test_FilterArraySetup')]
293+
#[Depends('test_filter_array_setup')]
294294
public function test_filter_pills_hide_on_reorder(array $filterDefaultArray): void
295295
{
296296
$filterDefaultArray['breed'] = [1];

tests/Unit/Traits/WithSortingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
final class WithSortingTest extends TestCase
88
{
9-
public function test_cannot_call_sortBy_if_sorting_is_disabled(): void
9+
public function test_cannot_call_sort_by_if_sorting_is_disabled(): void
1010
{
1111
$this->assertSame($this->basicTable->sortBy('id'), 'asc');
1212

tests/Unit/Views/Columns/DateColumnTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final class DateColumnTest extends TestCase
1111
{
12-
public function setUp(): void
12+
protected function setUp(): void
1313
{
1414
parent::setUp();
1515
parent::setupPetOwnerTable();

0 commit comments

Comments
 (0)