Skip to content

Commit

Permalink
Merge branch 'v4'
Browse files Browse the repository at this point in the history
  • Loading branch information
babenkoivan committed Jun 18, 2024
2 parents 39dc516 + a046c8b commit 158e0a5
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 197 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/vendor
/composer.lock
/phpunit.xml
/.phpunit.cache
/.phpunit.result.cache
/.php_cs
/.php_cs.cache
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 @@ -33,9 +33,11 @@ Elastic Migrations for Laravel allow you to easily modify and share indices sche

The current version of Elastic Migrations 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-migrations/tree/v3.4.1#compatibility) of the package.

## Installation

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
}
},
"require": {
"php": "^7.4 || ^8.0",
"babenkoivan/elastic-adapter": "^3.2"
"php": "^8.2",
"babenkoivan/elastic-adapter": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^11.0",
"orchestra/testbench": "^9.0",
"friendsofphp/php-cs-fixer": "^3.14",
"phpstan/phpstan": "^1.10",
"dg/bypass-finals": "^1.3"
"dg/bypass-finals": "^1.7"
},
"config": {
"bin-dir": "bin",
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ includes:

parameters:
level: max
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
paths:
- src
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
- '#Parameter .+? of method Illuminate\\Support\\Collection<.+?>::.+?\(\) expects .+? given#'
30 changes: 14 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
<?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"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
bootstrap="vendor/autoload.php" executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<file>src/ServiceProvider.php</file>
</exclude>
</coverage>
colors="true"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="false">
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">tests/Unit</directory>
Expand All @@ -29,4 +19,12 @@
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<file>src/ServiceProvider.php</file>
</exclude>
</source>
</phpunit>
68 changes: 19 additions & 49 deletions tests/Integration/Adapters/IndexManagerAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Elastic\Adapter\Indices\Settings;
use Elastic\Migrations\Adapters\IndexManagerAdapter;
use Elastic\Migrations\Tests\Integration\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;

/**
* @covers \Elastic\Migrations\Adapters\IndexManagerAdapter
*/
#[CoversClass(IndexManagerAdapter::class)]
final class IndexManagerAdapterTest extends TestCase
{
private MockObject $indexManagerMock;
Expand All @@ -26,9 +26,7 @@ protected function setUp(): void
$this->indexManagerAdapter = new IndexManagerAdapter($this->indexManagerMock);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_index_can_be_created_without_modifier(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -43,9 +41,7 @@ public function test_index_can_be_created_without_modifier(string $indexNamePref
$this->indexManagerAdapter->create($indexName);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_index_can_be_created_with_modifier(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -69,9 +65,7 @@ public function test_index_can_be_created_with_modifier(string $indexNamePrefix)
$this->indexManagerAdapter->create($indexName, $modifier);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_index_can_be_created_with_raw_mapping(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -94,9 +88,7 @@ public function test_index_can_be_created_with_raw_mapping(string $indexNamePref
$this->indexManagerAdapter->createRaw($indexName, $mapping);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_index_with_modifier_can_be_created_only_if_it_does_not_exist(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -117,9 +109,7 @@ public function test_index_with_modifier_can_be_created_only_if_it_does_not_exis
$this->indexManagerAdapter->createIfNotExists($indexName);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_index_with_raw_mapping_can_be_created_only_if_it_does_not_exist(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand Down Expand Up @@ -148,9 +138,7 @@ public function test_index_with_raw_mapping_can_be_created_only_if_it_does_not_e
$this->indexManagerAdapter->createIfNotExistsRaw($indexName, $mapping);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_mapping_can_be_updated_using_modifier(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -172,9 +160,7 @@ public function test_mapping_can_be_updated_using_modifier(string $indexNamePref
$this->indexManagerAdapter->putMapping($indexName, $modifier);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_mapping_can_be_updated_using_raw_input(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -195,9 +181,7 @@ public function test_mapping_can_be_updated_using_raw_input(string $indexNamePre
$this->indexManagerAdapter->putMappingRaw($indexName, $mapping);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_settings_can_be_updated_using_modifier(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -219,9 +203,7 @@ public function test_settings_can_be_updated_using_modifier(string $indexNamePre
$this->indexManagerAdapter->putSettings($indexName, $modifier);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_settings_can_be_updated_using_raw_input(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -237,9 +219,7 @@ public function test_settings_can_be_updated_using_raw_input(string $indexNamePr
$this->indexManagerAdapter->putSettingsRaw($indexName, $settings);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_settings_can_be_pushed_using_modifier(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand Down Expand Up @@ -271,9 +251,7 @@ public function test_settings_can_be_pushed_using_modifier(string $indexNamePref
$this->indexManagerAdapter->pushSettings($indexName, $modifier);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_settings_can_be_pushed_using_raw_input(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -299,9 +277,7 @@ public function test_settings_can_be_pushed_using_raw_input(string $indexNamePre
$this->indexManagerAdapter->pushSettingsRaw($indexName, $settings);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_index_can_be_dropped(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -316,9 +292,7 @@ public function test_index_can_be_dropped(string $indexNamePrefix): void
$this->indexManagerAdapter->drop($indexName);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_index_can_be_dropped_only_if_exists(string $indexNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.index', $indexNamePrefix);
Expand All @@ -339,9 +313,7 @@ public function test_index_can_be_dropped_only_if_exists(string $indexNamePrefix
$this->indexManagerAdapter->dropIfExists($indexName);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_alias_can_be_created(string $aliasNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.alias', $aliasNamePrefix);
Expand All @@ -357,9 +329,7 @@ public function test_alias_can_be_created(string $aliasNamePrefix): void
$this->indexManagerAdapter->putAlias($indexName, $aliasName);
}

/**
* @dataProvider prefixProvider
*/
#[DataProvider('prefixProvider')]
public function test_alias_can_be_deleted(string $aliasNamePrefix): void
{
$this->config->set('elastic.migrations.prefixes.alias', $aliasNamePrefix);
Expand Down Expand Up @@ -387,7 +357,7 @@ public function test_connection_can_be_changed(): void
$this->indexManagerAdapter->connection($connection);
}

public function prefixProvider(): array
public static function prefixProvider(): array
{
return [
'no prefix' => [''],
Expand Down
5 changes: 2 additions & 3 deletions tests/Integration/Console/FreshCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
use Elastic\Migrations\Migrator;
use Elastic\Migrations\Repositories\MigrationRepository;
use Elastic\Migrations\Tests\Integration\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;

/**
* @covers \Elastic\Migrations\Console\FreshCommand
*/
#[CoversClass(FreshCommand::class)]
final class FreshCommandTest extends TestCase
{
private MockObject $migrator;
Expand Down
5 changes: 2 additions & 3 deletions tests/Integration/Console/MakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use Elastic\Migrations\Console\MakeCommand;
use Elastic\Migrations\Filesystem\MigrationStorage;
use Elastic\Migrations\Tests\Integration\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;

/**
* @covers \Elastic\Migrations\Console\MakeCommand
*/
#[CoversClass(MakeCommand::class)]
final class MakeCommandTest extends TestCase
{
public function test_migration_file_can_be_created(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Integration/Console/MigrateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
use Elastic\Migrations\Console\MigrateCommand;
use Elastic\Migrations\Migrator;
use Elastic\Migrations\Tests\Integration\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;

/**
* @covers \Elastic\Migrations\Console\MigrateCommand
*/
#[CoversClass(MigrateCommand::class)]
final class MigrateCommandTest extends TestCase
{
private MockObject $migrator;
Expand Down
Loading

0 comments on commit 158e0a5

Please sign in to comment.