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

Fixes tests #68

Merged
merged 8 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
operating-system: [ ubuntu-20.04 ]
php-versions: ['8.1']
php-versions: ['8.1', '8.2', '8.3']

name: PHP ${{ matrix.php-versions }} Test
steps:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,12 @@ if ($success) {

This will save all audit info for your objects, as well as audits for any associated data. Please note, `$result` must
be an instance of an Object. Do not change the text "Model.afterCommit".

## Testing

By default, the test suite will not run elastic. If you are an elastic user and wish to test against a local instance
then you will need to set the environment variable:

```console
elastic_dsn="Cake\ElasticSearch\Datasource\Connection://127.0.0.1:9200?driver=Cake\ElasticSearch\Datasource\Connection" vendor/bin/phpunit
```
27 changes: 7 additions & 20 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
<?php
declare(strict_types=1);

/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 0.0.1
* @license https://www.opensource.org/licenses/mit-license.php MIT License
*/
require dirname(__DIR__) . '/vendor/autoload.php';

define('CAKE', dirname(__DIR__) . '/vendor/cakephp/cakephp/src/');
Expand Down Expand Up @@ -43,14 +30,14 @@
'path' => sys_get_temp_dir(),
]);

if (!getenv('DB_URL')) {
putenv('DB_URL=Cake\ElasticSearch\Datasource\Connection://elasticsearch:9200?driver=Cake\ElasticSearch\Datasource\Connection');
}

ConnectionManager::setConfig('elastic', ['url' => getenv('DB_URL')]);
ConnectionManager::setConfig('test_elastic', ['url' => getenv('DB_URL')]);
/**
* To run with elastic search tests locally:
*
* elastic_dsn="Cake\ElasticSearch\Datasource\Connection://127.0.0.1:9200?driver=Cake\ElasticSearch\Datasource\Connection" vendor/bin/phpunit
*/
ConnectionManager::setConfig('test_elastic', ['url' => env('elastic_dsn')]);

if (env('FIXTURE_MAPPINGS_METADATA')) {
if (env('elastic_dsn') && env('FIXTURE_MAPPINGS_METADATA')) {
$schema = new MappingGenerator(env('FIXTURE_MAPPINGS_METADATA'), 'test_elastic');
$schema->reload();
Router::reload();
Expand Down