Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up: #94 Merge config from vendor #98

Merged
merged 16 commits into from
Mar 15, 2020

Conversation

ametad
Copy link
Contributor

@ametad ametad commented Mar 13, 2020

At my first attempt I forgot to begin with a new branch and got in trouble ;) Here is the second attempt.

Closes #84

@ametad ametad mentioned this pull request Mar 13, 2020
@ametad
Copy link
Contributor Author

ametad commented Mar 13, 2020

Still have some problem with testing the config is there before- and after 'booting' the ServiceProvider. The config seems to be there all the time, already!

(#94 (comment))

I try some more.

@ametad
Copy link
Contributor Author

ametad commented Mar 13, 2020

I think this includes everything you want to :)

  • Merge the config from the package
  • Feature test, is the config available in the application
  • Changelog
  • Version bump

Is this ready to merge?

CHANGELOG.md Outdated Show resolved Hide resolved
{
\File::delete(config_path('elasticsearch.php'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I know better way to test it.
Revert your changes in this test. We don't need new test method
Delete this file https://github.com/matchish/laravel-scout-elasticsearch/blob/master/tests/laravel/config/elasticsearch.php
After it a lot of tests should fail
Add your code $this->mergeConfigFrom(__DIR__.'/../config/elasticsearch.php it should fix them because of now we load config from vendor package
And move this code to the end of the test for cleanup
File::delete(config_path('elasticsearch.php'))

@matchish
Copy link
Owner

No, I was wrong we need two tests
test_config_publishing
Need to add to the end \File::delete(config_path('elasticsearch.php')); to clean up after test

test_config_is_merged_from_the_package
call register then boot
assert that config not false

And we should override this method in our test class

protected function getEnvironmentSetUp($app)

And unset elasticsearch config

matchish and others added 7 commits March 14, 2020 11:00
(cherry picked from commit 189ac56)
Now mariadb-client is installed by default

(cherry picked from commit 26aac07)
(cherry picked from commit a797d18)
(cherry picked from commit 103c666)
(cherry picked from commit 50d4f31)
@ametad
Copy link
Contributor Author

ametad commented Mar 14, 2020

And unset elasticsearch config

The thing is, I think config keys cannot be unset at runtime. This is a problem, because a lot of testing needs the config set in \Tests\TestCase::getEnvironmentSetUp and therefore cannot be removed easily there.

Perhaps a local override of getEnvironmentSetUp that removes the elasticsearch config only for \Matchish\ScoutElasticSearch\ScoutElasticSearchServiceProviderTest. I will try that. This doesn't work for the same reason, config keys cannot be unset at runtime.

@ametad
Copy link
Contributor Author

ametad commented Mar 14, 2020

In cb02255 you see I moved the config needed for the Elastiscsearch integrations tests to it's base class.

Now the config is not loaded already in ScoutElasticSearchServiceProviderTest and we can test if the config is merged correctly from the package itself.

@matchish matchish merged commit 31482f5 into matchish:master Mar 15, 2020
@matchish
Copy link
Owner

Great contribution! Thanks)

@ametad ametad deleted the merge-config branch March 15, 2020 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load config from vendor
3 participants