From 88219cc1d1102ea23aec3209f32be8a74ea5e2f6 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:34:52 +0000 Subject: [PATCH 1/4] Add Missing Tests --- .../Unit/Traits/Helpers/ToolsHelpersTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/Unit/Traits/Helpers/ToolsHelpersTest.php b/tests/Unit/Traits/Helpers/ToolsHelpersTest.php index d7ea6c6f0..24182bc61 100644 --- a/tests/Unit/Traits/Helpers/ToolsHelpersTest.php +++ b/tests/Unit/Traits/Helpers/ToolsHelpersTest.php @@ -111,4 +111,30 @@ public function test_can_get_tools_display(): void $this->assertFalse($this->basicTable->shouldShowTools()); } + + public function test_can_get_tools_status_no_sortpills(): void + { + $this->assertTrue($this->basicTable->shouldShowTools()); + + $this->basicTable->setToolsEnabled(); + $this->basicTable->setSortingDisabled(); + $this->basicTable->setToolBarDisabled(); + $this->assertFalse($this->basicTable->shouldShowTools()); + + $this->basicTable->setFiltersEnabled(); + $this->basicTable->setFilter('pet_name_filter', 'Test'); + + $this->assertTrue($this->basicTable->shouldShowTools()); + + + } + + public function test_can_get_tools_status_toolbar_disabled(): void + { + $this->assertTrue($this->basicTable->shouldShowTools()); + $this->basicTable->setToolsEnabled(); + $this->basicTable->setToolBarDisabled(); + $this->assertFalse($this->basicTable->shouldShowToolBar()); + + } } From 60bbc447fad7e3c6e5bf6b0698b03af62d79f64c Mon Sep 17 00:00:00 2001 From: lrljoe Date: Thu, 21 Nov 2024 22:35:16 +0000 Subject: [PATCH 2/4] Fix styling --- .../AutoInjectRappasoftAssetsTest.php | 8 ++++---- .../RappasoftFrontendAssetsTest.php | 20 +++++++++---------- .../ColumnSelectConfigurationTest.php | 2 +- .../Unit/Traits/Helpers/ToolsHelpersTest.php | 1 - .../Unit/Traits/Visuals/FilterVisualsTest.php | 4 ++-- .../Traits/Visuals/ReorderingVisualsTest.php | 2 +- tests/Unit/Traits/WithSortingTest.php | 2 +- tests/Unit/Views/Columns/DateColumnTest.php | 2 +- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/tests/Unit/Features/AutoInjectRappasoftAssetsTest.php b/tests/Unit/Features/AutoInjectRappasoftAssetsTest.php index 6986967a9..39678175d 100644 --- a/tests/Unit/Features/AutoInjectRappasoftAssetsTest.php +++ b/tests/Unit/Features/AutoInjectRappasoftAssetsTest.php @@ -7,7 +7,7 @@ final class AutoInjectRappasoftAssetsTest extends TestCase { - public function test_shouldInjectRappasoftAndThirdParty() + public function test_should_inject_rappasoft_and_third_party() { config()->set('livewire-tables.inject_core_assets_enabled', true); config()->set('livewire-tables.inject_third_party_assets_enabled', true); @@ -20,7 +20,7 @@ public function test_shouldInjectRappasoftAndThirdParty() $this->assertStringContainsStringIgnoringCase('', $injectionReturn); } - public function test_shouldNotInjectRappasoftOrThirdParty() + public function test_should_not_inject_rappasoft_or_third_party() { config()->set('livewire-tables.inject_core_assets_enabled', false); config()->set('livewire-tables.inject_third_party_assets_enabled', false); @@ -30,7 +30,7 @@ public function test_shouldNotInjectRappasoftOrThirdParty() $this->assertEquals(' ', AutoInjectRappasoftAssets::injectAssets('')); } - public function test_shouldOnlyInjectThirdParty() + public function test_should_only_inject_third_party() { config()->set('livewire-tables.inject_core_assets_enabled', false); config()->set('livewire-tables.inject_third_party_assets_enabled', true); @@ -41,7 +41,7 @@ public function test_shouldOnlyInjectThirdParty() $this->assertStringContainsStringIgnoringCase('', $injectionReturn); } - public function test_shouldOnlyInjectRappasoft() + public function test_should_only_inject_rappasoft() { config()->set('livewire-tables.inject_core_assets_enabled', true); config()->set('livewire-tables.inject_third_party_assets_enabled', false); diff --git a/tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php b/tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php index ec6a8738e..1ef940c26 100644 --- a/tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php +++ b/tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php @@ -8,7 +8,7 @@ class RappasoftFrontendAssetsTest extends TestCase { - public function test_JsResponseSetupCacheEnabled(): array + public function test_js_response_setup_cache_enabled(): array { config()->set('livewire-tables.cache_assets', true); $lastModified = \Carbon\Carbon::now()->timestamp; @@ -22,7 +22,7 @@ public function test_JsResponseSetupCacheEnabled(): array return ['lastModified' => $lastModified, 'responseHeaders' => $response->headers->all()]; } - public function test_JsResponseSetupCacheDisabled(): array + public function test_js_response_setup_cache_disabled(): array { config()->set('livewire-tables.cache_assets', false); $date = date_create(); @@ -36,7 +36,7 @@ public function test_JsResponseSetupCacheDisabled(): array return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()]; } - public function test_CssResponseSetupCacheEnabled(): array + public function test_css_response_setup_cache_enabled(): array { config()->set('livewire-tables.cache_assets', true); $date = date_create(); @@ -50,7 +50,7 @@ public function test_CssResponseSetupCacheEnabled(): array return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()]; } - public function test_CssResponseSetupCacheDisabled(): array + public function test_css_response_setup_cache_disabled(): array { config()->set('livewire-tables.cache_assets', false); @@ -66,7 +66,7 @@ public function test_CssResponseSetupCacheDisabled(): array return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()]; } - public function test_ThirdPartyCssResponseSetupCacheEnabled(): array + public function test_third_party_css_response_setup_cache_enabled(): array { config()->set('livewire-tables.cache_assets', true); @@ -82,7 +82,7 @@ public function test_ThirdPartyCssResponseSetupCacheEnabled(): array return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()]; } - public function test_ThirdPartyCssResponseSetupCacheDisabled(): array + public function test_third_party_css_response_setup_cache_disabled(): array { config()->set('livewire-tables.cache_assets', false); @@ -98,7 +98,7 @@ public function test_ThirdPartyCssResponseSetupCacheDisabled(): array return ['lastModified' => date_timestamp_get($date), 'responseHeaders' => $response->headers->all()]; } - public function test_ThirdPartyJsResponseSetupCacheEnabled(): array + public function test_third_party_js_response_setup_cache_enabled(): array { config()->set('livewire-tables.cache_assets', true); $lastModified = \Carbon\Carbon::now()->timestamp; @@ -112,7 +112,7 @@ public function test_ThirdPartyJsResponseSetupCacheEnabled(): array return ['lastModified' => $lastModified, 'responseHeaders' => $response->headers->all()]; } - public function test_ThirdPartyJsResponseSetupCacheDisabled(): array + public function test_third_party_js_response_setup_cache_disabled(): array { config()->set('livewire-tables.cache_assets', false); $date = date_create(); @@ -148,7 +148,7 @@ public function test_scripts() $this->assertTrue($assets->hasRenderedRappsoftTableScripts); } - public function test_thirdPartystyles() + public function test_third_partystyles() { $assets = app(RappasoftFrontendAssets::class); @@ -159,7 +159,7 @@ public function test_thirdPartystyles() $this->assertTrue($assets->hasRenderedRappsoftTableThirdPartyStyles); } - public function test_thirdPartyscripts() + public function test_third_partyscripts() { $assets = app(RappasoftFrontendAssets::class); diff --git a/tests/Unit/Traits/Configuration/ColumnSelectConfigurationTest.php b/tests/Unit/Traits/Configuration/ColumnSelectConfigurationTest.php index 447a44974..891e2b8ea 100644 --- a/tests/Unit/Traits/Configuration/ColumnSelectConfigurationTest.php +++ b/tests/Unit/Traits/Configuration/ColumnSelectConfigurationTest.php @@ -12,7 +12,7 @@ public function test_variables_are_correct_types(): void $this->assertIsArray($this->basicTable->selectedColumns); } - public function test_check_protected_fields_columnSelectStatus(): void + public function test_check_protected_fields_column_select_status(): void { $this->expectException(\Livewire\Exceptions\PropertyNotFoundException::class); $this->assertIsBool($this->basicTable->columnSelectStatus); diff --git a/tests/Unit/Traits/Helpers/ToolsHelpersTest.php b/tests/Unit/Traits/Helpers/ToolsHelpersTest.php index 24182bc61..f0f5347b5 100644 --- a/tests/Unit/Traits/Helpers/ToolsHelpersTest.php +++ b/tests/Unit/Traits/Helpers/ToolsHelpersTest.php @@ -126,7 +126,6 @@ public function test_can_get_tools_status_no_sortpills(): void $this->assertTrue($this->basicTable->shouldShowTools()); - } public function test_can_get_tools_status_toolbar_disabled(): void diff --git a/tests/Unit/Traits/Visuals/FilterVisualsTest.php b/tests/Unit/Traits/Visuals/FilterVisualsTest.php index a1d474ab5..09b27ab9c 100644 --- a/tests/Unit/Traits/Visuals/FilterVisualsTest.php +++ b/tests/Unit/Traits/Visuals/FilterVisualsTest.php @@ -49,14 +49,14 @@ public function test_filter_pills_show_when_enabled(): void ->assertSee('Applied Filters'); } - public function test_event_dispatched_when_filterComponents_set(): void + public function test_event_dispatched_when_filter_components_set(): void { Livewire::test(PetsTable::class) ->set('filterComponents.breed', [1]) ->assertDispatched('filter-was-set'); } - public function test_event_dispatched_when_setFilter_dispatched(): void + public function test_event_dispatched_when_set_filter_dispatched(): void { Livewire::test(PetsTable::class) ->dispatch('setFilter', filterKey: 'breed', value: [1]) diff --git a/tests/Unit/Traits/Visuals/ReorderingVisualsTest.php b/tests/Unit/Traits/Visuals/ReorderingVisualsTest.php index efc3f8a73..dfa85025e 100644 --- a/tests/Unit/Traits/Visuals/ReorderingVisualsTest.php +++ b/tests/Unit/Traits/Visuals/ReorderingVisualsTest.php @@ -9,7 +9,7 @@ final class ReorderingVisualsTest extends TestCase { - public function test_FilterArraySetup(): array + public function test_filter_array_setup(): array { $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]; $this->assertNotEmpty($filterDefaultArray); diff --git a/tests/Unit/Traits/WithSortingTest.php b/tests/Unit/Traits/WithSortingTest.php index 2b7ae66f8..3aeed356b 100644 --- a/tests/Unit/Traits/WithSortingTest.php +++ b/tests/Unit/Traits/WithSortingTest.php @@ -6,7 +6,7 @@ final class WithSortingTest extends TestCase { - public function test_cannot_call_sortBy_if_sorting_is_disabled(): void + public function test_cannot_call_sort_by_if_sorting_is_disabled(): void { $this->assertSame($this->basicTable->sortBy('id'), 'asc'); diff --git a/tests/Unit/Views/Columns/DateColumnTest.php b/tests/Unit/Views/Columns/DateColumnTest.php index 42985b0d6..1b3e96a94 100644 --- a/tests/Unit/Views/Columns/DateColumnTest.php +++ b/tests/Unit/Views/Columns/DateColumnTest.php @@ -9,7 +9,7 @@ final class DateColumnTest extends TestCase { - public function setUp(): void + protected function setUp(): void { parent::setUp(); parent::setupPetOwnerTable(); From 93db2dadcda89fe3da2309e3be90560a674c7b2d Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:49:51 +0000 Subject: [PATCH 3/4] Update Test Names --- .../RappasoftFrontendAssetsTest.php | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php b/tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php index 1ef940c26..3d354e1e4 100644 --- a/tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php +++ b/tests/Unit/Mechanisms/RappasoftFrontendAssetsTest.php @@ -170,97 +170,97 @@ public function test_third_partyscripts() $this->assertTrue($assets->hasRenderedRappsoftTableThirdPartyScripts); } - #[Depends('test_JsResponseSetupCacheEnabled')] + #[Depends('test_js_response_setup_cache_enabled')] public function test_check_pretend_response_is_js_returns_correct_cache_control_cache_enabled(array $jsResponseSetupCacheEnabled) { $this->assertSame('max-age=86400, public', $jsResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]); } - #[Depends('test_JsResponseSetupCacheEnabled')] + #[Depends('test_js_response_setup_cache_enabled')] public function test_check_pretend_response_is_js_returns_correct_content_type_cache_enabled(array $jsResponseSetupCacheEnabled) { $this->assertSame('application/javascript; charset=utf-8', $jsResponseSetupCacheEnabled['responseHeaders']['content-type'][0]); } - #[Depends('test_JsResponseSetupCacheDisabled')] + #[Depends('test_js_response_setup_cache_disabled')] public function test_check_pretend_response_is_js_returns_correct_cache_control_cache_disabled(array $jsResponseSetupCacheDisabled) { $this->assertSame('max-age=1, public', $jsResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]); } - #[Depends('test_JsResponseSetupCacheDisabled')] + #[Depends('test_js_response_setup_cache_disabled')] public function test_check_pretend_response_is_js_returns_correct_content_type_cache_disabled(array $jsResponseSetupCacheDisabled) { $this->assertSame('application/javascript; charset=utf-8', $jsResponseSetupCacheDisabled['responseHeaders']['content-type'][0]); } - #[Depends('test_CssResponseSetupCacheEnabled')] + #[Depends('test_css_response_setup_cache_enabled')] public function test_check_pretend_response_is_css_returns_correct_cache_control_caching_enabled(array $cssResponseSetupCacheEnabled) { $this->assertSame('max-age=86400, public', $cssResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]); } - #[Depends('test_CssResponseSetupCacheEnabled')] + #[Depends('test_css_response_setup_cache_enabled')] public function test_check_pretend_response_is_css_returns_correct_content_type_caching_enabled(array $cssResponseSetupCacheEnabled) { $this->assertSame('text/css; charset=utf-8', $cssResponseSetupCacheEnabled['responseHeaders']['content-type'][0]); } - #[Depends('test_CssResponseSetupCacheDisabled')] + #[Depends('test_css_response_setup_cache_disabled')] public function test_check_pretend_response_is_css_returns_correct_cache_control_caching_disabled(array $cssResponseSetupCacheDisabled) { $this->assertSame('max-age=1, public', $cssResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]); } - #[Depends('test_CssResponseSetupCacheDisabled')] + #[Depends('test_css_response_setup_cache_disabled')] public function test_check_pretend_response_is_css_returns_correct_content_type_caching_disabled(array $cssResponseSetupCacheDisabled) { $this->assertSame('text/css; charset=utf-8', $cssResponseSetupCacheDisabled['responseHeaders']['content-type'][0]); } - #[Depends('test_ThirdPartyCssResponseSetupCacheEnabled')] + #[Depends('test_third_party_css_response_setup_cache_enabled')] public function test_tp_check_pretend_response_is_css_returns_correct_cache_control_caching_enabled(array $thirdPartyCssResponseSetupCacheEnabled) { $this->assertSame('max-age=86400, public', $thirdPartyCssResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]); } - #[Depends('test_ThirdPartyCssResponseSetupCacheEnabled')] + #[Depends('test_third_party_css_response_setup_cache_enabled')] public function test_tp_check_pretend_response_is_css_returns_correct_content_type_caching_enabled(array $thirdPartyCssResponseSetupCacheEnabled) { $this->assertSame('text/css; charset=utf-8', $thirdPartyCssResponseSetupCacheEnabled['responseHeaders']['content-type'][0]); } - #[Depends('test_ThirdPartyCssResponseSetupCacheDisabled')] + #[Depends('test_third_party_css_response_setup_cache_disabled')] public function test_tp_check_pretend_response_is_css_returns_correct_cache_control_caching_disabled(array $thirdPartyCssResponseSetupCacheDisabled) { $this->assertSame('max-age=1, public', $thirdPartyCssResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]); } - #[Depends('test_ThirdPartyCssResponseSetupCacheDisabled')] + #[Depends('test_third_party_css_response_setup_cache_disabled')] public function test_tp_check_pretend_response_is_css_returns_correct_content_type_caching_disabled(array $thirdPartyCssResponseSetupCacheDisabled) { $this->assertSame('text/css; charset=utf-8', $thirdPartyCssResponseSetupCacheDisabled['responseHeaders']['content-type'][0]); } - #[Depends('test_ThirdPartyJsResponseSetupCacheEnabled')] + #[Depends('test_third_party_js_response_setup_cache_enabled')] public function test_tp_check_pretend_response_is_js_returns_correct_cache_control_cache_enabled(array $thirdPartyJsResponseSetupCacheEnabled) { $this->assertSame('max-age=86400, public', $thirdPartyJsResponseSetupCacheEnabled['responseHeaders']['cache-control'][0]); } - #[Depends('test_ThirdPartyJsResponseSetupCacheEnabled')] + #[Depends('test_third_party_js_response_setup_cache_enabled')] public function test_tp_check_pretend_response_is_js_returns_correct_content_type_cache_enabled(array $thirdPartyJsResponseSetupCacheEnabled) { $this->assertSame('application/javascript; charset=utf-8', $thirdPartyJsResponseSetupCacheEnabled['responseHeaders']['content-type'][0]); } - #[Depends('test_ThirdPartyJsResponseSetupCacheDisabled')] + #[Depends('test_third_party_js_response_setup_cache_disabled')] public function test_tp_check_pretend_response_is_js_returns_correct_cache_control_cache_disabled(array $thirdPartyJsResponseSetupCacheDisabled) { $this->assertSame('max-age=1, public', $thirdPartyJsResponseSetupCacheDisabled['responseHeaders']['cache-control'][0]); } - #[Depends('test_ThirdPartyJsResponseSetupCacheDisabled')] + #[Depends('test_third_party_js_response_setup_cache_disabled')] public function test_tp_check_pretend_response_is_js_returns_correct_content_type_cache_disabled(array $thirdPartyJsResponseSetupCacheDisabled) { $this->assertSame('application/javascript; charset=utf-8', $thirdPartyJsResponseSetupCacheDisabled['responseHeaders']['content-type'][0]); From e871239bc915355c56ded1a8afc83bb9b2d29b1a Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:51:07 +0000 Subject: [PATCH 4/4] test_filter_array_setup --- tests/Unit/Traits/Visuals/ReorderingVisualsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Unit/Traits/Visuals/ReorderingVisualsTest.php b/tests/Unit/Traits/Visuals/ReorderingVisualsTest.php index dfa85025e..5ee1071aa 100644 --- a/tests/Unit/Traits/Visuals/ReorderingVisualsTest.php +++ b/tests/Unit/Traits/Visuals/ReorderingVisualsTest.php @@ -95,7 +95,7 @@ public function test_sorting_pills_hide_on_reorder(): void ->assertSeeHtml('wire:key="table-sorting-pill-id"'); } - #[Depends('test_FilterArraySetup')] + #[Depends('test_filter_array_setup')] public function test_sorting_is_disabled_on_reorder(array $filterDefaultArray): void { Livewire::test(PetsTable::class) @@ -169,7 +169,7 @@ public function test_per_page_gets_set_on_reorder(): void ->assertSet('perPage', 10); } - #[Depends('test_FilterArraySetup')] + #[Depends('test_filter_array_setup')] public function test_search_hides_on_reorder(array $filterDefaultArray): void { Livewire::test(PetsTable::class) @@ -267,7 +267,7 @@ public function test_bulk_actions_row_select_some_gets_hidden_on_reorder(): void ->assertDontSee('do you want to select all'); } - #[Depends('test_FilterArraySetup')] + #[Depends('test_filter_array_setup')] public function test_filters_are_disabled_on_reorder(array $filterDefaultArray): void { $customisedFilterArray = $filterDefaultArray; @@ -290,7 +290,7 @@ public function test_filters_are_disabled_on_reorder(array $filterDefaultArray): ->assertSeeHtml('Filters'); } - #[Depends('test_FilterArraySetup')] + #[Depends('test_filter_array_setup')] public function test_filter_pills_hide_on_reorder(array $filterDefaultArray): void { $filterDefaultArray['breed'] = [1];