File tree Expand file tree Collapse file tree 3 files changed +73
-1
lines changed
__fixtures__/resources/fieldsets Expand file tree Collapse file tree 3 files changed +73
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ public function all(): Collection
3030 ->setContents ($ model ->data );
3131 });
3232 });
33- });
33+ })
34+ ->merge ($ this ->getNamespacedFieldsets ());
3435 }
3536
3637 public function find ($ handle ): ?Fieldset
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tests \Data \Fields ;
4+
5+ use Illuminate \Foundation \Testing \RefreshDatabase ;
6+ use PHPUnit \Framework \Attributes \Test ;
7+ use Statamic \Facades \Fieldset ;
8+ use Tests \TestCase ;
9+
10+ class FieldsetTest extends TestCase
11+ {
12+ use RefreshDatabase;
13+
14+ protected function setUp (): void
15+ {
16+ parent ::setUp ();
17+
18+ $ this ->app ->singleton (
19+ 'Statamic\Fields\FieldsetRepository ' ,
20+ 'Statamic\Eloquent\Fields\FieldsetRepository '
21+ );
22+
23+ $ this ->app ->bind ('statamic.eloquent.fieldsets.model ' , function () {
24+ return \Statamic \Eloquent \Fields \FieldsetModel::class;
25+ });
26+ }
27+
28+ #[Test]
29+ public function it_handles_fieldsets_registered_by_addons ()
30+ {
31+ $ this ->assertCount (0 , Fieldset::all ());
32+
33+ Fieldset::addNamespace (
34+ 'my-addon ' ,
35+ directory: __DIR__ .'/../../__fixtures__/resources/fieldsets '
36+ );
37+
38+ $ this ->assertCount (1 , Fieldset::all ());
39+ $ this ->assertSame ('my-addon::seo ' , Fieldset::all ()->first ()->handle ());
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ title : ' Advanced SEO (Sitemap)'
2+ fields :
3+ -
4+ handle : seo_section_sitemap
5+ field :
6+ type : advanced_seo
7+ display : ' Sitemap'
8+ field : seo_section_sitemap
9+ visibility : hidden
10+ -
11+ handle : seo_sitemap_enabled
12+ field :
13+ type : advanced_seo
14+ display : ' Enabled'
15+ field : seo_sitemap_enabled
16+ visibility : hidden
17+ -
18+ handle : seo_sitemap_priority
19+ field :
20+ type : advanced_seo
21+ display : ' Priority'
22+ field : seo_sitemap_priority
23+ visibility : hidden
24+ -
25+ handle : seo_sitemap_change_frequency
26+ field :
27+ type : advanced_seo
28+ display : ' Change Frequency'
29+ field : seo_sitemap_change_frequency
30+ visibility : hidden
You can’t perform that action at this time.
0 commit comments