Skip to content

Commit

Permalink
Merge pull request #98 from ametad/merge-config
Browse files Browse the repository at this point in the history
Follow up: #94 Merge config from vendor
  • Loading branch information
matchish authored Mar 15, 2020
2 parents 623716c + 6d8ae71 commit 31482f5
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 42 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/)

## [Unreleased]


## [3.0.3] - 2020-03-14
### Added
- Load config from package [#84](https://github.com/matchish/laravel-scout-elasticsearch/issues/84)

## [3.0.2] - 2020-03-14
### Added
- Populate routing meta-field [#90](https://github.com/matchish/laravel-scout-elasticsearch/issues/90)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "matchish/laravel-scout-elasticsearch",
"description": "Search among multiple models with ElasticSearch and Laravel Scout",
"version": "3.0.2",
"version": "3.0.3",
"keywords": [
"laravel",
"scout",
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
user: "1000:1000"
depends_on:
- elasticsearch
- db
volumes:
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
Expand Down
2 changes: 2 additions & 0 deletions src/ElasticSearchServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ final class ElasticSearchServiceProvider extends ServiceProvider
*/
public function register(): void
{
$this->mergeConfigFrom(__DIR__.'/../config/elasticsearch.php', 'elasticsearch');

$this->app->bind(Client::class, function () {
return ClientBuilder::create()->setHosts([config('elasticsearch.host')])->build();
});
Expand Down
15 changes: 12 additions & 3 deletions tests/Feature/ScoutElasticSearchServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@

class ScoutElasticSearchServiceProviderTest extends TestCase
{
public function test_config_is_merged_from_the_package()
{
$distConfig = require __DIR__.'/../../config/elasticsearch.php';

$this->assertSame($distConfig, config('elasticsearch'));
}

public function test_config_publishing()
{
\File::delete(config_path('elasticsearch.php'));
$provider = new ElasticSearchServiceProvider($this->app);
$provider->register();
$provider->boot();

\Artisan::call('vendor:publish', [
$this->artisan('vendor:publish', [
'--tag' => 'config',
]);
])->assertExitCode(0);

$this->assertFileExists(config_path('elasticsearch.php'));

\File::delete(config_path('elasticsearch.php'));
}

public function test_provides()
Expand Down
17 changes: 17 additions & 0 deletions tests/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,21 @@ public function setUp(): void

$this->elasticsearch->indices()->delete(['index' => '_all']);
}

protected function getEnvironmentSetUp($app)
{
parent::getEnvironmentSetUp($app);

$app['config']->set('elasticsearch', require(__DIR__.'/../config/elasticsearch.php'));
$app['config']->set('elasticsearch.indices.mappings.products', [
'properties' => [
'type' => [
'type' => 'keyword',
],
'price' => [
'type' => 'integer',
],
],
]);
}
}
11 changes: 0 additions & 11 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ protected function getEnvironmentSetUp($app)
$app['config']->set('scout.queue', false);
// Setup default database to use sqlite :memory:
$app['config']->set('database.default', 'mysql');
$app['config']->set('elasticsearch', require(__DIR__.'/../config/elasticsearch.php'));
$app['config']->set('elasticsearch.indices.mappings.products', [
'properties' => [
'type' => [
'type' => 'keyword',
],
'price' => [
'type' => 'integer',
],
],
]);
}

protected function getPackageProviders($app)
Expand Down
27 changes: 0 additions & 27 deletions tests/laravel/config/elasticsearch.php

This file was deleted.

0 comments on commit 31482f5

Please sign in to comment.