From 9f2920b6662bdfdaeb8593309bf65243fc109716 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Tue, 24 Oct 2017 20:09:26 +0800 Subject: [PATCH] Add config for the package --- src/ServiceProvider.php | 6 +++++- src/config.php | 39 +++++++++++++++++++++++++++++++++++++++ tests/ConfigTest.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/config.php create mode 100644 tests/ConfigTest.php diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 295c2f3..3478546 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -16,10 +16,14 @@ class ServiceProvider extends BaseServiceProvider CrudMake::class, ]); } + + $this->mergeConfigFrom(__DIR__ . '/config.php', 'simple-crud'); } public function boot() { - // + $this->publishes([ + __DIR__ . '/config.php' => config_path('simple-crud.php'), + ], 'config'); } } diff --git a/src/config.php b/src/config.php new file mode 100644 index 0000000..0f62936 --- /dev/null +++ b/src/config.php @@ -0,0 +1,39 @@ + 'layouts.app', + + /* + |-------------------------------------------------------------------------- + | Base Test Class Path + |-------------------------------------------------------------------------- + | + | Base TestCase Path on Laravel application + | + */ + + 'base_test_path' => 'tests/BrowserKitTest.php', + + /* + |-------------------------------------------------------------------------- + | Base Test Class + |-------------------------------------------------------------------------- + | + | Base Test Class that used on Laravel application + | according to 'base_test_path' config above + | + */ + + 'base_test_class' => 'Tests\BrowserKitTest', + +]; diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php new file mode 100644 index 0000000..dd89c84 --- /dev/null +++ b/tests/ConfigTest.php @@ -0,0 +1,44 @@ +assertTrue(is_array(config('simple-crud'))); + } + + /** @test */ + public function it_has_default_layout_view_config() + { + $this->assertEquals('layouts.app', config('simple-crud.default_layout_view')); + + config(['simple-crud.default_layout_view' => 'layouts.master']); + + $this->assertEquals('layouts.master', config('simple-crud.default_layout_view')); + } + + /** @test */ + public function it_has_base_test_path_config() + { + $this->assertEquals('tests/BrowserKitTest.php', config('simple-crud.base_test_path')); + } + + /** @test */ + public function it_has_base_test_class_config() + { + $this->assertEquals('Tests\BrowserKitTest', config('simple-crud.base_test_class')); + } + + /** @test */ + public function config_file_can_be_published() + { + $this->artisan('vendor:publish', ['--tag' => 'config', '--no-interaction' => true]); + + $this->assertFileExists(config_path('simple-crud.php')); + + $this->removeFileOrDir(config_path('simple-crud.php')); + } +}