elastic-scout-driver icon indicating copy to clipboard operation
elastic-scout-driver copied to clipboard

Unable to set `refresh_documents` in `phpunit.xml` due to strict bool checking

Open stevebauman opened this issue 3 years ago • 0 comments

Software Version
PHP 8.0
Elasticsearch 7.*
Laravel 9.*
Laravel Scout 9.*

Describe the bug Due to:

https://github.com/babenkoivan/elastic-scout-driver/blob/9b15115c886c2fada0be9e14b92d70c6ec7bbcc3/src/Engine.php#L38

And:

https://github.com/babenkoivan/elastic-adapter/blob/50e9559774c09688a0f5024c964ab22b97c554de/src/Documents/DocumentManager.php#L22

We can't supply a "truthy" value to refresh_documents in our phpunit.xml:

<!-- ... -->
<php>
    <env name="ELASTIC_SCOUT_DRIVER_REFRESH_DOCUMENTS" value="1"/>
    <!-- ... -->
</php>

An exception is thrown:

TypeError: ElasticAdapter\Documents\DocumentManager::index(): Argument #3 ($refresh) must be of type bool, string given

To Reproduce

  1. Publish the configuration file
  2. Add <env name="ELASTIC_SCOUT_DRIVER_REFRESH_DOCUMENTS" value="1"/> to your phpunit.xml
  3. Run a test

Expected behavior We should cast the value to a boolean before passing it to the DocumentManager.

stevebauman avatar Aug 04 '22 18:08 stevebauman