Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed3mar committed Feb 8, 2025
1 parent 9f67715 commit 843e6f9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
5 changes: 2 additions & 3 deletions config/service_provider.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package config

import (
"github.com/goravel/framework/contracts"
"github.com/goravel/framework/contracts/foundation"
"github.com/goravel/framework/support"
)

const Binding = "goravel.config"

type ServiceProvider struct {
}

func (config *ServiceProvider) Register(app foundation.Application) {
app.Singleton(Binding, func(app foundation.Application) (any, error) {
app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return NewApplication(support.EnvPath), nil
})
}
Expand Down
9 changes: 5 additions & 4 deletions console/service_provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package console

import (
"github.com/goravel/framework/console/console"
"github.com/goravel/framework/contracts"
consolecontract "github.com/goravel/framework/contracts/console"
"github.com/goravel/framework/contracts/foundation"
Expand All @@ -10,7 +11,7 @@ import (
type ServiceProvider struct {
}

func (console *ServiceProvider) Register(app foundation.Application) {
func (r *ServiceProvider) Register(app foundation.Application) {
app.Singleton(contracts.BindingConsole, func(app foundation.Application) (any, error) {
name := "artisan"
usage := "Goravel Framework"
Expand All @@ -19,11 +20,11 @@ func (console *ServiceProvider) Register(app foundation.Application) {
})
}

func (console *ServiceProvider) Boot(app foundation.Application) {
console.registerCommands(app)
func (r *ServiceProvider) Boot(app foundation.Application) {
r.registerCommands(app)
}

func (console *ServiceProvider) registerCommands(app foundation.Application) {
func (r *ServiceProvider) registerCommands(app foundation.Application) {
artisanFacade := app.MakeArtisan()
if artisanFacade == nil {
color.Warningln("Artisan Facade is not initialized. Skipping command registration.")
Expand Down
1 change: 1 addition & 0 deletions contracts/binding.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package contracts

const (
BindingConfig = "goravel.config"
BindingConsole = "goravel.console"
BindingAuth = "goravel.auth"
BindingGate = "goravel.gate"
Expand Down
30 changes: 15 additions & 15 deletions foundation/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (s *ApplicationTestSuite) TestLangPath() {
mockConfig := mocksconfig.NewConfig(s.T())
mockConfig.EXPECT().GetString("app.lang_path", "lang").Return("test").Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})

Expand Down Expand Up @@ -154,7 +154,7 @@ func (s *ApplicationTestSuite) TestMakeAuth() {
mockConfig := mocksconfig.NewConfig(s.T())
mockConfig.EXPECT().GetString("auth.defaults.guard").Return("user").Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})
s.app.Singleton(contracts.BindingCache, func(app foundation.Application) (any, error) {
Expand All @@ -176,7 +176,7 @@ func (s *ApplicationTestSuite) TestMakeCache() {
mockConfig.EXPECT().GetString("cache.stores.memory.driver").Return("memory").Once()
mockConfig.EXPECT().GetString("cache.prefix").Return("goravel").Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})
s.app.Singleton(contracts.BindingLog, func(app foundation.Application) (any, error) {
Expand All @@ -200,7 +200,7 @@ func (s *ApplicationTestSuite) TestMakeCrypt() {
mockConfig := mocksconfig.NewConfig(s.T())
mockConfig.EXPECT().GetString("app.key").Return("12345678901234567890123456789012").Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})
s.app.SetJson(json.NewJson())
Expand Down Expand Up @@ -230,7 +230,7 @@ func (s *ApplicationTestSuite) TestMakeGate() {
}

func (s *ApplicationTestSuite) TestMakeGrpc() {
s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return &mocksconfig.Config{}, nil
})

Expand All @@ -247,7 +247,7 @@ func (s *ApplicationTestSuite) TestMakeHash() {
mockConfig.EXPECT().GetInt("hashing.argon2id.memory", 65536).Return(65536).Once()
mockConfig.EXPECT().GetInt("hashing.argon2id.threads", 1).Return(1).Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})

Expand All @@ -263,7 +263,7 @@ func (s *ApplicationTestSuite) TestMakeLang() {
mockConfig.EXPECT().GetString("app.fallback_locale").Return("en").Once()
mockConfig.EXPECT().GetString("app.lang_path", "lang").Return("lang").Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})
s.app.Singleton(contracts.BindingLog, func(app foundation.Application) (any, error) {
Expand All @@ -279,7 +279,7 @@ func (s *ApplicationTestSuite) TestMakeLang() {

func (s *ApplicationTestSuite) TestMakeLog() {
mockConfig := mocksconfig.NewConfig(s.T())
s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})

Expand All @@ -294,7 +294,7 @@ func (s *ApplicationTestSuite) TestMakeLog() {
}

func (s *ApplicationTestSuite) TestMakeMail() {
s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return &mocksconfig.Config{}, nil
})
s.app.Singleton(contracts.BindingQueue, func(app foundation.Application) (any, error) {
Expand Down Expand Up @@ -341,7 +341,7 @@ func (s *ApplicationTestSuite) TestMakeOrm() {
mockConfig.EXPECT().GetInt("database.pool.conn_max_idletime", 3600).Return(3600).Once()
mockConfig.EXPECT().GetInt("database.pool.conn_max_lifetime", 3600).Return(3600).Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})

Expand All @@ -356,7 +356,7 @@ func (s *ApplicationTestSuite) TestMakeOrm() {
}

func (s *ApplicationTestSuite) TestMakeQueue() {
s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return &mocksconfig.Config{}, nil
})

Expand All @@ -380,7 +380,7 @@ func (s *ApplicationTestSuite) TestMakeRateLimiter() {
func (s *ApplicationTestSuite) TestMakeRoute() {
mockConfig := mocksconfig.NewConfig(s.T())

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})

Expand All @@ -395,7 +395,7 @@ func (s *ApplicationTestSuite) TestMakeSchedule() {
mockConfig := mocksconfig.NewConfig(s.T())
mockConfig.EXPECT().GetBool("app.debug").Return(false).Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})
s.app.Singleton(contracts.BindingConsole, func(app foundation.Application) (any, error) {
Expand All @@ -420,7 +420,7 @@ func (s *ApplicationTestSuite) TestMakeSession() {
mockConfig.EXPECT().GetInt("session.gc_interval", 30).Return(30).Once()
mockConfig.EXPECT().GetString("session.files").Return("storage/framework/sessions").Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})
s.app.SetJson(json.NewJson())
Expand All @@ -440,7 +440,7 @@ func (s *ApplicationTestSuite) TestMakeStorage() {
mockConfig.EXPECT().GetString("filesystems.disks.local.root").Return("").Once()
mockConfig.EXPECT().GetString("filesystems.disks.local.url").Return("").Once()

s.app.Singleton(frameworkconfig.Binding, func(app foundation.Application) (any, error) {
s.app.Singleton(contracts.BindingConfig, func(app foundation.Application) (any, error) {
return mockConfig, nil
})

Expand Down
3 changes: 1 addition & 2 deletions foundation/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"sync"

"github.com/goravel/framework/config"
"github.com/goravel/framework/contracts"
contractsauth "github.com/goravel/framework/contracts/auth"
contractsaccess "github.com/goravel/framework/contracts/auth/access"
Expand Down Expand Up @@ -100,7 +99,7 @@ func (c *Container) MakeCache() contractscache.Cache {
}

func (c *Container) MakeConfig() contractsconfig.Config {
instance, err := c.Make(config.Binding)
instance, err := c.Make(contracts.BindingConfig)
if err != nil {
color.Errorln(err)
return nil
Expand Down

0 comments on commit 843e6f9

Please sign in to comment.