Ejemplo n.º 1
0
func TestAllowedCountriesFound(t *testing.T) {
	cr := config.NewMockReader(
		config.WithMockValues(config.MockPV{
			config.MockPathScopeStore(1, directory.PathCountryAllowed): "DE,AU,CH,AT",
		}),
	)

	haveCountries, err := directory.AllowedCountries(cr.NewScoped(1, 1, 1))
	assert.NoError(t, err)
	assert.Exactly(t, utils.StringSlice{"DE", "AU", "CH", "AT"}, haveCountries)
}
Ejemplo n.º 2
0
func init() {
	middlewareConfigReader = config.NewMockReader(
		config.WithMockValues(config.MockPV{
			config.MockPathScopeDefault(store.PathRedirectToBase):    1,
			config.MockPathScopeStore(1, store.PathSecureInFrontend): true,
			config.MockPathScopeStore(1, store.PathUnsecureBaseURL):  "http://www.corestore.io/",
			config.MockPathScopeStore(1, store.PathSecureBaseURL):    "https://www.corestore.io/",
		}),
	)

	middlewareCtxStoreService = storemock.NewContextService(
		scope.Option{},
		func(ms *storemock.Storage) {
			ms.MockStore = func() (*store.Store, error) {
				return store.NewStore(
					&store.TableStore{StoreID: 1, Code: dbr.NewNullString("de"), WebsiteID: 1, GroupID: 1, Name: "Germany", SortOrder: 10, IsActive: true},
					&store.TableWebsite{WebsiteID: 1, Code: dbr.NewNullString("euro"), Name: dbr.NewNullString("Europe"), SortOrder: 0, DefaultGroupID: 1, IsDefault: dbr.NewNullBool(true)},
					&store.TableGroup{GroupID: 1, WebsiteID: 1, Name: "DACH Group", RootCategoryID: 2, DefaultStoreID: 2},
					store.SetStoreConfig(middlewareConfigReader),
				)
			}
		},
	)
}
Ejemplo n.º 3
0
func TestSourceCurrencyAll(t *testing.T) {

	r := config.NewMockReader(
		config.MockString(func(path string) string {
			t.Log(path)
			switch path {
			case config.MockPathScopeStore(1, directory.PathDefaultLocale):
				return "de_CH"
			}
			return "Not Found"
		}),
	)

	s := config.ScopeID(1)

	sca := directory.NewSourceCurrencyAll(config.ModelConstructor{
		ConfigReader: r,
		Scope:        s,
	})

	t.Logf("\n%#v\n", sca.Options())

}
Ejemplo n.º 4
0
func TestSourceCurrencyAll(t *testing.T) {

	r := config.NewMockReader(
		config.WithMockString(func(path string) (string, error) {
			t.Log(path)
			switch path {
			case config.MockPathScopeStore(1, directory.PathDefaultLocale):
				return "de_CH", nil
			}
			return "Not Found", nil
		}),
	)

	var s scope.MockID = 1

	sca := directory.NewSourceCurrencyAll(config.ModelConstructor{
		ConfigReader: r,
		ScopeStore:   s,
	})

	t.Logf("\n%#v\n", sca.Options())

}