Skip to content

Commit

Permalink
update deps, fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen-G committed Dec 25, 2024
1 parent f935042 commit eb3ac7b
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
php: [8.0, 8.1, 8.2, 8.3]
php: [8.2, 8.3, 8.4]
experimental: [ false ]
include:
- php: 8.4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
php: [8.1, 8.2, 8.3]
php: [8.2, 8.3, 8.4]

name: Mutation Testing Code Review Annotations ${{ matrix.php }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/node_modules
/report
.phpunit.result.cache
.phpunit.cache
composer.lock
infection.log
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- ElasticSearch 7 support: the elastic 8 client is not backwards compatible. See 'changed' for the breaking changes.
- Support for Laravel 9 and below to make package maintenance easier.
- Support for PHP 8.0 and 8.1, as required by Laravel.

### Changed

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"homepage": "https://jeroen-g.github.io/Explorer/",
"keywords": ["Laravel", "Scout", "Elasticsearch", "Elastic", "search", "Explorer"],
"require": {
"php": "^8.0",
"php": "^8.2",
"elasticsearch/elasticsearch": "^8.0",
"illuminate/support": "^9.0||^10.0||^11.0",
"laravel/scout": "^9.0||^10.0||^11.0",
"illuminate/support": "^11.0",
"laravel/scout": "^10.0",
"webmozart/assert": "^1.10",
"psr/log": "^1|^2|^3"
"psr/log": "^3"
},
"require-dev": {
"phpunit/phpunit": "~9.0",
"phpunit/phpunit": "^10.0",
"mockery/mockery": "^1.5",
"infection/infection": "^0.26",
"infection/infection": "^0.29",
"symplify/easy-coding-standard": "^9.0",
"nunomaduro/larastan": "^2.5",
"phpstan/phpstan-mockery": "^1.1",
Expand Down
12 changes: 6 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="unit">
<directory suffix=".php">./tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src/</directory>
</include>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/Domain/Syntax/RegExp.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
class RegExp implements SyntaxInterface
{
private string $field;

private ?string $value;

private string $flags;

private bool $insensitive;

public function __construct(string $field, string $value = null, string $flags = 'ALL', bool $insensitive = false)
public function __construct(string $field, ?string $value = null, string $flags = 'ALL', bool $insensitive = false)
{
$this->field = $field;
$this->value = $value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php
declare(strict_types=1);

namespace JeroenG\Explorer\Tests\Unit;
namespace JeroenG\Explorer\Tests\Support;

use Elastic\Elasticsearch\Client;
use Elastic\Elasticsearch\ClientInterface;
use Mockery;
use Mockery\MockInterface;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);

namespace JeroenG\Explorer\Tests\Unit;
namespace JeroenG\Explorer\Tests\Support;

use Elastic\Elasticsearch\Response\Elasticsearch;
use GuzzleHttp\Psr7\Response;
Expand Down
6 changes: 3 additions & 3 deletions tests/Support/QueryTypeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

trait QueryTypeProvider
{
public function getQueryTypes(): array
public static function getQueryTypes(): array
{
return QueryType::ALL;
}

public function queryTypeProvider(): array
public static function queryTypeProvider(): array
{
return array_map(fn ($item) => [$item], $this->getQueryTypes());
return array_map(fn ($item) => [$item], self::getQueryTypes());
}
}
6 changes: 3 additions & 3 deletions tests/Support/SyntaxProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

trait SyntaxProvider
{
public function syntaxProvider(): array
public static function syntaxProvider(): array
{
return array_map(fn ($item) => [$item], $this->getSyntaxClasses());
return array_map(fn ($item) => [$item], self::getSyntaxClasses());
}

public function getSyntaxClasses(): array
public static function getSyntaxClasses(): array
{
return [
Matching::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function test_it_builds_empty_array(): void
Assert::assertSame([], SourceFilter::empty()->build());
}

public function provideSourceFilterValues(): iterable
public static function provideSourceFilterValues(): iterable
{
yield 'include 2 fields' => [
[ 'include' => ['a', 'b'] ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function test_it_tracks_none(): void
Assert::assertSame([ 'track_total_hits' => false ], TrackTotalHits::none()->build());
}

public function provideTrackTotalHitCounts(): iterable
public static function provideTrackTotalHitCounts(): iterable
{
yield 'count 100' => [100];
yield 'count -100' => [-100];
Expand Down
18 changes: 9 additions & 9 deletions tests/Unit/Domain/Syntax/SortOrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
use PHPUnit\Framework\TestCase;

final class SortOrderTest extends TestCase
{
{
public function test_it_uses_default_missing_when_creating_sort_order(): void
{
$sort = SortOrder::for(SortOrder::DESCENDING);

Assert::assertSame([
'missing' => SortOrder::MISSING_LAST,
'order' => SortOrder::DESCENDING
], $sort->build());
}

/**
* @dataProvider provideSortOrderStrings
*/
Expand All @@ -26,7 +26,7 @@ public function test_sort_order_can_be_created_from_sort_string(string $expected
$subject = SortOrder::fromString($sortString);
Assert::assertSame($expectedResult, $subject->build());
}

/**
* @dataProvider provideMissingSortOrderStrings
*/
Expand All @@ -35,18 +35,18 @@ public function test_sort_order_can_be_created_from_sort_string_and_missing(arra
$subject = SortOrder::for($sortString, $missing);
Assert::assertSame($expectedResult, $subject->build());
}
public function provideSortOrderStrings(): iterable

public static function provideSortOrderStrings(): iterable
{
yield 'asc' => ['asc', 'asc'];
yield 'desc' => ['desc', 'desc'];
}
public function provideMissingSortOrderStrings(): iterable

public static function provideMissingSortOrderStrings(): iterable
{
yield 'asc order with _last missing' => [['missing' => '_last', 'order' => 'asc'], 'asc', '_last'];
yield 'desc order with _last missing' => [['missing' => '_last', 'order' => 'desc'], 'desc', '_last'];
yield 'asc order with _first missing' => [['missing' => '_first', 'order' => 'asc'], 'asc', '_first'];
yield 'desc order with _first missing' => [['missing' => '_first', 'order' => 'desc'], 'desc', '_first'];
}
}
}
2 changes: 1 addition & 1 deletion tests/Unit/ElasticClientBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function test_it_creates_client_with_config(array $config, ClientBuilder
self::assertEquals($expectedBuilder, $resultBuilder);
}

public function provideClientConfigs(): ?\Generator
public static function provideClientConfigs(): ?\Generator
{
yield 'simple host' => [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ElasticClientFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace JeroenG\Explorer\Tests\Unit;

use Elastic\Elasticsearch\ClientInterface;
use JeroenG\Explorer\Application\SearchCommand;
use JeroenG\Explorer\Domain\Query\Query;
use JeroenG\Explorer\Domain\Syntax\Compound\BoolQuery;
use JeroenG\Explorer\Infrastructure\Elastic\ElasticClientFactory;
use JeroenG\Explorer\Infrastructure\Elastic\FakeResponse;
use JeroenG\Explorer\Infrastructure\Elastic\Finder;
use JeroenG\Explorer\Tests\Support\ClientExpectation;
use Mockery;
use Mockery\Adapter\Phpunit\MockeryTestCase;

Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use JeroenG\Explorer\Application\AggregationResult;
use JeroenG\Explorer\Application\SearchCommand;
use JeroenG\Explorer\Domain\Aggregations\MaxAggregation;
use JeroenG\Explorer\Domain\Aggregations\NestedAggregation;
use JeroenG\Explorer\Domain\Aggregations\NestedFilteredAggregation;
use JeroenG\Explorer\Domain\Aggregations\TermsAggregation;
use JeroenG\Explorer\Domain\Query\Query;
Expand All @@ -17,8 +18,9 @@
use JeroenG\Explorer\Domain\Syntax\Term;
use JeroenG\Explorer\Infrastructure\Elastic\Finder;
use JeroenG\Explorer\Infrastructure\Scout\ScoutSearchCommandBuilder;
use JeroenG\Explorer\Tests\Support\ClientExpectation;
use JeroenG\Explorer\Tests\Support\FakeElasticResponse;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use JeroenG\Explorer\Domain\Aggregations\NestedAggregation;

class FinderTest extends MockeryTestCase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use JeroenG\Explorer\Tests\Support\Models\TestModelWithoutSettings;
use JeroenG\Explorer\Tests\Support\Models\TestModelWithSettings;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use RuntimeException;
use StdClass;

final class ElasticIndexConfigurationRepositoryTest extends MockeryTestCase
{
Expand Down Expand Up @@ -105,14 +107,14 @@ public function test_it_can_create_the_configuration_from_a_class_without_settin

public function test_it_throws_on_invalid_model(): void
{
$indices = [
self::class
];
$indices = [get_class(new StdClass())];

$repository = new ElasticIndexConfigurationRepository($indices);

$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage(sprintf('Unable to create index %s, ensure it implements Explored', self::class));
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage(
sprintf('Unable to create index %s, ensure it implements Explored', get_class(new StdClass()))
);
iterator_to_array($repository->getConfigurations())[0] ?? null;
}

Expand All @@ -121,12 +123,12 @@ public function test_it_errors_on_invalid_indices($indices, string $error): void
{
$repository = new ElasticIndexConfigurationRepository($indices);

$this->expectException(\RuntimeException::class);
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage($error);
iterator_to_array($repository->getConfigurations());
}

public function invalidIndices(): iterable
public static function invalidIndices(): iterable
{
yield [
[false],
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/IndexManagement/IndexAliasConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function test_it_can_get_the_different_aliases(string $alias, string $met
self::assertSame("shipIt-$alias", $config->$method());
}

public function aliasProvider(): \Generator
public static function aliasProvider(): \Generator
{
yield ['history', 'getHistoryAliasName'];
yield ['write', 'getWriteAliasName'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Operations/Bulk/BulkUpdateOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function test_it_builds_from_sources($input): void
], $operation->build());
}

public function iterableInputDataProvider(): \Generator
public static function iterableInputDataProvider(): \Generator
{
yield 'collection' => [collect([new TestModelWithoutSettings()])];
yield 'array' => [[new TestModelWithoutSettings()]];
Expand Down
Loading

0 comments on commit eb3ac7b

Please sign in to comment.