Skip to content

Commit

Permalink
Add Laravel 11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
babenkoivan committed May 20, 2024
1 parent f2bd15d commit 57f437c
Show file tree
Hide file tree
Showing 31 changed files with 138 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install php and composer
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none
tools: composer:v2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install php and composer
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
coverage: none
tools: composer:v2

Expand Down
16 changes: 4 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.4, 8.0, 8.1]
php: [8.2]
include:
- php: 7.4
testbench: 6.0
phpunit: 9.5

- php: 8.0
testbench: 7.0
phpunit: 9.5

- php: 8.1
testbench: 8.0
phpunit: 9.5
- php: 8.2
testbench: 9.0
phpunit: 11.0
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'compact_nullable_typehint' => true,
'compact_nullable_type_declaration' => true,
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'dir_constant' => true,
'self_static_accessor' => false,
'fully_qualified_strict_types' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'type_declaration_spaces' => true,
'header_comment' => false,
'list_syntax' => ['syntax' => 'short'],
'lowercase_cast' => true,
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ operations.

The current version of Elastic Adapter has been tested with the following configuration:

* PHP 7.4-8.x
* PHP 8.2
* Elasticsearch 8.x
* Laravel 6.x-10.x
* Laravel 11.x

If your project uses older Laravel (or PHP) version check [the previous major version](https://github.com/babenkoivan/elastic-adapter/tree/v3.5.0#compatibility) of the package.

## Installation

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
},
"require": {
"php": "^7.4 || ^8.0",
"babenkoivan/elastic-client": "^2.1"
"babenkoivan/elastic-client": "v3.x-dev"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^11.0",
"friendsofphp/php-cs-fixer": "^3.14",
"phpstan/phpstan": "^1.10",
"orchestra/testbench": "^8.0",
"dg/bypass-finals": "^1.3"
"orchestra/testbench": "^9.0",
"dg/bypass-finals": "^1.7"
},
"config": {
"bin-dir": "bin",
Expand Down
Empty file removed phpstan-baseline.neon
Empty file.
7 changes: 2 additions & 5 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
includes:
- phpstan-baseline.neon

parameters:
level: max
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
paths:
- src
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Unable to resolve the template type (TKey|TValue) in call to function collect#'
- '#Parameter .+? of method Illuminate\\Support\\Collection<.+?>::.+?\(\) expects .+? given#'
37 changes: 18 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
colors="true">
<extensions>
<extension class="Elastic\Adapter\Tests\Extensions\BypassFinalExtension" />
</extensions>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">tests/Unit</directory>
</testsuite>
</testsuites>
colors="true"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true">
<extensions>
<bootstrap class="Elastic\Adapter\Tests\Extensions\BypassFinals"/>
</extensions>
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">tests/Unit</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
5 changes: 1 addition & 4 deletions src/Indices/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ final class Mapping implements Arrayable
private ?bool $isSourceEnabled;
private MappingProperties $properties;
private array $dynamicTemplates = [];
/**
* @var string|bool|null
*/
private $dynamic;
private string|bool|null $dynamic;

public function __construct()
{
Expand Down
14 changes: 0 additions & 14 deletions tests/Extensions/BypassFinalExtension.php

This file was deleted.

19 changes: 19 additions & 0 deletions tests/Extensions/BypassFinals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php declare(strict_types=1);

namespace Elastic\Adapter\Tests\Extensions;

use PHPUnit\Runner\Extension\Extension;
use PHPUnit\Runner\Extension\Facade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;

final class BypassFinals implements Extension
{
public function bootstrap(
Configuration $configuration,
Facade $facade,
ParameterCollection $parameters
): void {
\DG\BypassFinals::enable(false);
}
}
20 changes: 10 additions & 10 deletions tests/Unit/Documents/DocumentManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
use Elastic\Adapter\Exceptions\BulkOperationException;
use Elastic\Adapter\Search\Hit;
use Elastic\Adapter\Search\SearchParameters;
use Elastic\Adapter\Search\SearchResult;
use Elastic\Client\ClientBuilderInterface;
use Elastic\Elasticsearch\Client;
use Elastic\Elasticsearch\Response\Elasticsearch;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use stdClass;

/**
* @covers \Elastic\Adapter\Documents\DocumentManager
*
* @uses \Elastic\Adapter\Documents\Document
* @uses \Elastic\Adapter\Documents\Routing
* @uses \Elastic\Adapter\Exceptions\BulkOperationException
* @uses \Elastic\Adapter\Search\Hit
* @uses \Elastic\Adapter\Search\SearchParameters
* @uses \Elastic\Adapter\Search\SearchResult
*/
#[CoversClass(DocumentManager::class)]
#[UsesClass(Document::class)]
#[UsesClass(Routing::class)]
#[UsesClass(BulkOperationException::class)]
#[UsesClass(Hit::class)]
#[UsesClass(SearchParameters::class)]
#[UsesClass(SearchResult::class)]
final class DocumentManagerTest extends TestCase
{
private MockObject $client;
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Documents/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Elastic\Adapter\Tests\Unit\Documents;

use Elastic\Adapter\Documents\Document;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Elastic\Adapter\Documents\Document
*/
#[CoversClass(Document::class)]
final class DocumentTest extends TestCase
{
public function test_document_getters(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Documents/RoutingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Elastic\Adapter\Tests\Unit\Documents;

use Elastic\Adapter\Documents\Routing;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Elastic\Adapter\Documents\Routing
*/
#[CoversClass(Routing::class)]
final class RoutingTest extends TestCase
{
public function test_routing_values_can_be_added_and_retrieved(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Exceptions/BulkOperationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Elastic\Adapter\Tests\Unit\Exceptions;

use Elastic\Adapter\Exceptions\BulkOperationException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Elastic\Adapter\Exceptions\BulkOperationException
*/
#[CoversClass(BulkOperationException::class)]
final class BulkOperationExceptionTest extends TestCase
{
public function test_raw_result_can_be_retrieved(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Indices/AliasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Elastic\Adapter\Tests\Unit\Indices;

use Elastic\Adapter\Indices\Alias;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Elastic\Adapter\Indices\Alias
*/
#[CoversClass(Alias::class)]
final class AliasTest extends TestCase
{
public function test_alias_getters(): void
Expand Down
18 changes: 9 additions & 9 deletions tests/Unit/Indices/IndexManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
use Elastic\Adapter\Indices\Index;
use Elastic\Adapter\Indices\IndexManager;
use Elastic\Adapter\Indices\Mapping;
use Elastic\Adapter\Indices\MappingProperties;
use Elastic\Adapter\Indices\Settings;
use Elastic\Client\ClientBuilderInterface;
use Elastic\Elasticsearch\Client;
use Elastic\Elasticsearch\Endpoints\Indices;
use Elastic\Elasticsearch\Response\Elasticsearch;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @covers \Elastic\Adapter\Indices\IndexManager
*
* @uses \Elastic\Adapter\Indices\Alias
* @uses \Elastic\Adapter\Indices\Index
* @uses \Elastic\Adapter\Indices\Mapping
* @uses \Elastic\Adapter\Indices\MappingProperties
* @uses \Elastic\Adapter\Indices\Settings
*/
#[CoversClass(IndexManager::class)]
#[UsesClass(Alias::class)]
#[UsesClass(Index::class)]
#[UsesClass(Mapping::class)]
#[UsesClass(MappingProperties::class)]
#[UsesClass(Settings::class)]
class IndexManagerTest extends TestCase
{
private MockObject $indices;
Expand Down
9 changes: 4 additions & 5 deletions tests/Unit/Indices/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
use Elastic\Adapter\Indices\Index;
use Elastic\Adapter\Indices\Mapping;
use Elastic\Adapter\Indices\Settings;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Elastic\Adapter\Indices\Index
*
* @uses \Elastic\Adapter\Indices\Mapping
*/
#[CoversClass(Index::class)]
#[UsesClass(Mapping::class)]
class IndexTest extends TestCase
{
public function test_index_default_values(): void
Expand Down
15 changes: 7 additions & 8 deletions tests/Unit/Indices/MappingPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
use BadMethodCallException;
use Closure;
use Elastic\Adapter\Indices\MappingProperties;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;

/**
* @covers \Elastic\Adapter\Indices\MappingProperties
*/
#[CoversClass(MappingProperties::class)]
final class MappingPropertiesTest extends TestCase
{
public function parametersProvider(): array
public static function parametersProvider(): array
{
return [
[
Expand Down Expand Up @@ -150,11 +151,9 @@ public function parametersProvider(): array

/**
* @param Closure|array $parameters
*
* @dataProvider parametersProvider
*
* @testdox Test $type property setter
*/
#[DataProvider('parametersProvider')]
#[TestDox('Test $type property setter')]
public function test_property_setter(string $type, string $name, $parameters, array $expected): void
{
$actual = (new MappingProperties())->$type($name, $parameters);
Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/Indices/MappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Elastic\Adapter\Tests\Unit\Indices;

use Elastic\Adapter\Indices\Mapping;
use Elastic\Adapter\Indices\MappingProperties;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Elastic\Adapter\Indices\Mapping
*
* @uses \Elastic\Adapter\Indices\MappingProperties
*/
#[CoversClass(Mapping::class)]
#[UsesClass(MappingProperties::class)]
class MappingTest extends TestCase
{
public function test_field_names_can_be_disabled(): void
Expand Down
Loading

0 comments on commit 57f437c

Please sign in to comment.