-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop support for PHP 8.0 and doctrine/dbal 2.x (#39)
BREAKING CHANGES - Remove support for PHP 8.0 - Upgrade to only use doctrine/dbal:^3.8 - Remove code supporting version 2.x of doctrine/dbal - Use Symfony 6.4 components for development - Rename classes that had "ElasticSearch" to "Elasticsearch" - Upgrade to PHPUnit 10.5 - Fix tests - Update documentation - Upgrade CI workflow to use PHP 8.1
- Loading branch information
1 parent
b8d56ca
commit a1f549d
Showing
64 changed files
with
631 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- https://phpunit.readthedocs.io/en/9.6/ --> | ||
<!-- https://docs.phpunit.de/en/10.5/ --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd" bootstrap="vendor/autoload.php" | ||
colors="true" beStrictAboutChangesToGlobalState="true"> | ||
<coverage> | ||
<include> | ||
<directory>src</directory> | ||
</include> | ||
<report> | ||
<clover outputFile="tests/.results/tests-clover.xml"/> | ||
<html outputDirectory="tests/.results/html/"/> | ||
</report> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="DataFixtures Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<listeners> | ||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/> | ||
</listeners> | ||
<logging> | ||
<junit outputFile="tests/.results/tests-junit.xml"/> | ||
</logging> | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" | ||
colors="true" beStrictAboutChangesToGlobalState="true" testdox="true"> | ||
<coverage> | ||
<report> | ||
<clover outputFile="tests/.results/tests-clover.xml"/> | ||
<html outputDirectory="tests/.results/html/"/> | ||
</report> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="DataFixtures Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<logging> | ||
<junit outputFile="tests/.results/tests-junit.xml"/> | ||
</logging> | ||
<source> | ||
<include> | ||
<directory>src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Kununu\DataFixtures\Adapter; | ||
|
||
use Elasticsearch\Client; | ||
use Kununu\DataFixtures\Exception\LoadFailedException; | ||
use stdClass; | ||
|
||
abstract class ElasticsearchFileFixture extends AbstractFileLoaderFixture implements ElasticsearchFixtureInterface | ||
{ | ||
use ElasticsearchFixtureTrait; | ||
|
||
private const INDEX = 'index'; | ||
private const UPDATE = 'update'; | ||
private const ERROR = 'error'; | ||
|
||
public function load(Client $elasticSearch, string $indexName, bool $throwOnFail = true): void | ||
{ | ||
parent::loadFiles(fn(array $documents) => $this->bulk($elasticSearch, $indexName, $documents, $throwOnFail)); | ||
} | ||
|
||
private function bulk(Client $elasticSearch, string $indexName, array $documents, bool $throwOnFail): void | ||
{ | ||
if (empty($documents)) { | ||
return; | ||
} | ||
|
||
$result = $elasticSearch->bulk( | ||
array_merge( | ||
['body' => $this->prepareBodyForBulkIndexation($indexName, $documents)], | ||
is_string($documentType = $this->getDocumentType()) ? ['type' => $documentType] : [] | ||
) | ||
); | ||
|
||
if ($throwOnFail && ($result['errors'] ?? false)) { | ||
$errors = array_map( | ||
fn(array $item): stdClass => (object) [ | ||
self::INDEX => $item[self::UPDATE]['_index'], | ||
'id' => $item[self::UPDATE]['_id'], | ||
'status' => $item[self::UPDATE]['status'], | ||
self::ERROR => $item[self::UPDATE][self::ERROR], | ||
], | ||
array_filter( | ||
$result['items'] ?? [], | ||
fn(array $item): bool => isset($item[self::UPDATE][self::ERROR]) | ||
) | ||
); | ||
|
||
throw new LoadFailedException(static::class, $errors); | ||
} | ||
} | ||
} |
Oops, something went wrong.