@@ -235,4 +235,50 @@ public function createMultipleOrders()
235235 $ customerIds [$ orderWithCustomerFixture ->getCustomerId ()] = 1 ;
236236 self ::assertCount (3 , $ customerIds );
237237 }
238+
239+ /**
240+ * Create orders for faker addresses with either state or province. Assert both types have a `region_id` assigned.
241+ *
242+ * @test
243+ * @throws \Exception
244+ */
245+ public function createIntlOrders ()
246+ {
247+ $ atLocale = 'de_AT ' ;
248+ $ atOrder = OrderBuilder::anOrder ()
249+ ->withCustomer (
250+ CustomerBuilder::aCustomer ()->withAddresses (
251+ AddressBuilder::anAddress (null , $ atLocale )->asDefaultBilling ()->asDefaultShipping ()
252+ )
253+ )
254+ ->build ();
255+ $ this ->orderFixtures [] = new OrderFixture ($ atOrder );
256+
257+ $ usLocale = 'en_US ' ;
258+ $ usOrder = OrderBuilder::anOrder ()
259+ ->withCustomer (
260+ CustomerBuilder::aCustomer ()->withAddresses (
261+ AddressBuilder::anAddress (null , $ usLocale )->asDefaultBilling ()->asDefaultShipping ()
262+ )
263+ )
264+ ->build ();
265+ $ this ->orderFixtures [] = new OrderFixture ($ usOrder );
266+
267+ $ caLocale = 'en_CA ' ;
268+ $ caOrder = OrderBuilder::anOrder ()
269+ ->withCustomer (
270+ CustomerBuilder::aCustomer ()->withAddresses (
271+ AddressBuilder::anAddress (null , $ caLocale )->asDefaultBilling ()->asDefaultShipping ()
272+ )
273+ )
274+ ->build ();
275+ $ this ->orderFixtures [] = new OrderFixture ($ caOrder );
276+
277+ self ::assertSame (substr ($ atLocale , 3 , 4 ), $ atOrder ->getBillingAddress ()->getCountryId ());
278+ self ::assertNotEmpty ($ atOrder ->getBillingAddress ()->getRegionId ());
279+ self ::assertSame (substr ($ usLocale , 3 , 4 ), $ usOrder ->getBillingAddress ()->getCountryId ());
280+ self ::assertNotEmpty ($ usOrder ->getBillingAddress ()->getRegionId ());
281+ self ::assertSame (substr ($ caLocale , 3 , 4 ), $ caOrder ->getBillingAddress ()->getCountryId ());
282+ self ::assertNotEmpty ($ caOrder ->getBillingAddress ()->getRegionId ());
283+ }
238284}
0 commit comments