@@ -220,4 +220,42 @@ public function it_imports_blueprints_and_fieldsets_with_force_argument()
220220 $ this ->assertCount (1 , BlueprintModel::all ());
221221 $ this ->assertCount (1 , FieldsetModel::all ());
222222 }
223+
224+ #[Test]
225+ public function it_imports_namespaced_blueprints_and_fieldsets ()
226+ {
227+ BlueprintFacade::addNamespace ('myaddon ' , __DIR__ .'/__fixtures__/blueprints ' );
228+ FieldsetFacade::addNamespace ('myaddon ' , __DIR__ .'/__fixtures__/blueprints ' );
229+
230+ BlueprintFacade::make ('test ' )
231+ ->setNamespace ('myaddon ' )
232+ ->setContents ([
233+ 'fields ' => [
234+ ['handle ' => 'name ' , 'field ' => ['type ' => 'text ' ]],
235+ ['handle ' => 'email ' , 'field ' => ['type ' => 'text ' ], 'validate ' => 'required ' ],
236+ ],
237+ ])->save ();
238+
239+ FieldsetFacade::make ('myaddon::test ' )
240+ ->setContents ([
241+ 'fields ' => [
242+ ['handle ' => 'foo ' , 'field ' => ['type ' => 'text ' ]],
243+ ['handle ' => 'bar ' , 'field ' => ['type ' => 'textarea ' , 'validate ' => 'required ' ]],
244+ ],
245+ ])->save ();
246+
247+ $ this ->assertCount (0 , BlueprintModel::all ());
248+ $ this ->assertCount (0 , FieldsetModel::all ());
249+
250+ $ this ->artisan ('statamic:eloquent:import-blueprints ' , ['--force ' => true ])
251+ ->expectsOutputToContain ('Blueprints imported successfully. ' )
252+ ->expectsOutputToContain ('Fieldsets imported successfully. ' )
253+ ->assertExitCode (0 );
254+
255+ $ this ->assertCount (1 , BlueprintModel::all ());
256+ $ this ->assertCount (1 , FieldsetModel::all ());
257+
258+ $ this ->assertSame ('myaddon ' , BlueprintModel::first ()->namespace );
259+ $ this ->assertStringContainsString ('myaddon:: ' , FieldsetModel::first ()->handle );
260+ }
223261}
0 commit comments