Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
41 changes: 27 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ on:
schedule:
- cron: '0 3 * * 1'

env:
fail-fast: true

jobs:
integration-tests:
# Will not run if the event is a PR to bump-meilisearch-v* (so a pre-release PR)
Expand All @@ -30,15 +27,18 @@ jobs:
MEILI_NO_ANALYTICS: true
strategy:
matrix:
php-version: ['7.4', '8.1', '8.2', '8.3', '8.4']
sf-version: ['5.4', '6.4', '7.0', '7.1', '7.2', '7.3']
php-version: [ '7.4', '8.1', '8.2', '8.3', '8.4' ]
sf-version: [ '5.4', '6.4', '7.0', '7.1', '7.2', '7.3' ]
dependencies: [ 'default' ]
exclude:
- php-version: '7.4'
sf-version: '6.4'
- php-version: '7.4'
sf-version: '7.0'
- php-version: '7.4'
sf-version: '7.1'
- php-version: '7.4'
sf-version: '7.2'
- php-version: '7.4'
sf-version: '7.3'
- php-version: '8.1'
Expand All @@ -47,6 +47,8 @@ jobs:
sf-version: '7.0'
- php-version: '8.1'
sf-version: '7.1'
- php-version: '8.1'
sf-version: '7.2'
- php-version: '8.1'
sf-version: '7.3'
- php-version: '8.2'
Expand All @@ -55,14 +57,24 @@ jobs:
sf-version: '5.4'
- php-version: '8.4'
sf-version: '5.4'
include:
- php-version: '7.4'
sf-version: '7.2'
- php-version: '8.0'
sf-version: '7.2'
- php-version: '8.1'
sf-version: '7.2'
sf-version: '5.4'
dependencies: 'lowest'
- php-version: '7.4'
sf-version: '5.4'
dependencies: 'highest'
- php-version: '8.4'
sf-version: '6.4'
dependencies: 'lowest'
- php-version: '8.4'
sf-version: '6.4'
dependencies: 'highest'
- php-version: '8.4'
sf-version: '7.3'
dependencies: 'highest'

name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*)
name: integration-tests (PHP ${{ matrix.php-version }}) (Symfony ${{ matrix.sf-version }}.*)${{ matrix.dependencies != 'default' && format(' ({0})', matrix.dependencies) || '' }}
steps:
- name: Checkout code
uses: actions/checkout@v5
Expand All @@ -73,7 +85,7 @@ jobs:
php-version: ${{ matrix.php-version }}
tools: composer, flex

- name: Validate composer.json and composer.lock
- name: Validate composer.json
run: composer validate

- name: Remove doctrine/annotations
Expand All @@ -85,15 +97,16 @@ jobs:
env:
SYMFONY_REQUIRE: ${{ matrix.sf-version }}.*
with:
dependency-versions: 'highest'
composer-options: --no-interaction --no-progress --prefer-dist --dev
dependency-versions: "${{ matrix.dependencies }}"

- name: Run test suite
run: composer test:unit -- --coverage-clover coverage.xml

- name: Upload coverage file
uses: actions/upload-artifact@v4
with:
name: 'phpunit-${{ matrix.php-version }}-${{ matrix.sf-version }}-coverage'
name: "phpunit-${{ matrix.php-version }}-${{ matrix.sf-version }}-${{ matrix.dependencies }}-coverage"
path: 'coverage.xml'

code-style:
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
->setFinder($finder)
->setRules([
'@Symfony' => true,
'@PHP80Migration:risky' => true,
'@PHP8x0Migration:risky' => true,
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
'global_namespace_import' => [
'import_classes' => false,
Expand Down
27 changes: 14 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"require": {
"php": "^7.4|^8.0",
"ext-json": "*",
"doctrine/doctrine-bundle": "^2.10",
"meilisearch/meilisearch-php": "^1.0.0",
"doctrine/doctrine-bundle": "^2.10 || ^3.0",
"meilisearch/meilisearch-php": "^1.16",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.4.17 || ^6.0 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
Expand All @@ -34,21 +34,22 @@
"doctrine/annotations": "^2.0.0",
"doctrine/orm": "^2.12 || ^3.0",
"matthiasnoback/symfony-config-test": "^4.3 || ^5.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.0",
"nyholm/psr7": "^1.8.1",
"php-cs-fixer/shim": "^3.58.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.1",
"nikic/php-parser": "^5.6.2",
"nyholm/psr7": "^1.8.2",
"php-cs-fixer/shim": "^3.88.2",
"phpmd/phpmd": "^2.15",
"phpstan/extension-installer": "^1.4.1",
"phpstan/phpstan": "^1.11.4",
"phpstan/phpstan-doctrine": "^1.4.3",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpstan/phpstan-symfony": "^1.4.4",
"phpunit/php-code-coverage": "^9.2.31",
"phpstan/extension-installer": "^1.4.3",
"phpstan/phpstan": "^2.1.31",
"phpstan/phpstan-doctrine": "^2.0.10",
"phpstan/phpstan-phpunit": "^2.0.7",
"phpstan/phpstan-symfony": "^2.0.8",
"phpunit/php-code-coverage": "^9.2.32",
"symfony/doctrine-bridge": "^5.4.19 || ^6.0.7 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.4.17 || ^6.0 || ^7.0",
"symfony/http-client": "^5.4 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^6.4 || ^7.0",
"symfony/http-client": "^5.4.47 || ^6.4.15 || ^7.1.8",
"symfony/phpunit-bridge": "^7.3",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"autoload": {
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist → phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ parameters:
- tests
ignoreErrors:
- '#Call to static method getClass\(\) on an unknown class Doctrine\\Common\\Util\\ClassUtils#'
- '#Parameter \#1 \$array of function array_unique expects an array of values castable to string, list<class-string<Meilisearch\\Bundle\\Entity\\Aggregator>\|Meilisearch\\Bundle\\Entity\\Aggregator> given#'
2 changes: 1 addition & 1 deletion src/Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function clear(string $indexUid): array
/**
* Delete an index and its content.
*/
public function delete(string $indexUid): ?array
public function delete(string $indexUid): array
{
return $this->client->deleteIndex($indexUid);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Services/MeilisearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ public function clear(string $className): array
return $this->engine->clear($this->searchableAs($className));
}

public function deleteByIndexName(string $indexName): ?array
public function deleteByIndexName(string $indexName): array
{
return $this->engine->delete($indexName);
}

public function delete(string $className): ?array
public function delete(string $className): array
{
$this->assertIsSearchable($className);

Expand Down
33 changes: 18 additions & 15 deletions tests/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Meilisearch\Bundle\Tests;

use Doctrine\Bundle\DoctrineBundle\ConnectionFactory;
use Doctrine\Bundle\DoctrineBundle\Dbal\BlacklistSchemaAssetFilter;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\Mapping\LegacyReflectionFields;
use Meilisearch\Bundle\MeilisearchBundle;
use Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver;
Expand All @@ -29,18 +29,30 @@ public function registerBundles(): iterable

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config/framework.yaml');

$doctrineBundleV3 = !class_exists(BlacklistSchemaAssetFilter::class);

if (PHP_VERSION_ID >= 80000) {
if (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
$loader->load(__DIR__.'/config/config.yaml');
if ($doctrineBundleV3) {
$loader->load(__DIR__.'/config/doctrine.yaml');
} elseif (class_exists(LegacyReflectionFields::class) && PHP_VERSION_ID >= 80400) {
$loader->load(__DIR__.'/config/doctrine_v2.yaml');
} else {
$loader->load(__DIR__.'/config/config_old_proxy.yaml');
$loader->load(__DIR__.'/config/doctrine_old_proxy.yaml');
}
} else {
$loader->load(__DIR__.'/config/config_php7.yaml');
$container->prependExtensionConfig('framework', [
'annotations' => true,
'serializer' => ['enable_annotations' => true],
'router' => ['utf8' => true],
]);

$loader->load(__DIR__.'/config/doctrine_php7.yaml');
}
$loader->load(__DIR__.'/config/meilisearch.yaml');

if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) {
if (\defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP') && !$doctrineBundleV3) {
$container->prependExtensionConfig('doctrine', [
'orm' => [
'report_fields_where_declared' => true,
Expand All @@ -49,15 +61,6 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
]);
}

// @phpstan-ignore-next-line
if (method_exists(Configuration::class, 'setLazyGhostObjectEnabled') && Kernel::VERSION_ID >= 60100) {
$container->prependExtensionConfig('doctrine', [
'orm' => [
'enable_lazy_ghost_objects' => true,
],
]);
}

if (class_exists(EntityValueResolver::class)) {
$container->prependExtensionConfig('doctrine', [
'orm' => [
Expand Down
17 changes: 12 additions & 5 deletions tests/baseline-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
%Since symfony/var-exporter 7.3: The "Symfony\\Component\\VarExporter\\LazyGhostTrait" trait is deprecated, use native lazy objects instead.%
%Since symfony/var-exporter 7.3: Using ProxyHelper::generateLazyGhost\(\) is deprecated, use native lazy objects instead.%
%Class "Doctrine\\ORM\\Proxy\\Autoloader" is deprecated. Use native lazy objects instead.%
%Calling Doctrine\\ORM\\Configuration::setProxyDir is deprecated and will not be possible in Doctrine ORM 4.0%
%Calling Doctrine\\ORM\\Configuration::getProxyDir is deprecated and will not be possible in Doctrine ORM 4.0%
%Calling Doctrine\\ORM\\Configuration::setAutoGenerateProxyClasses is deprecated and will not be possible in Doctrine ORM 4.0%
%Calling Doctrine\\ORM\\Configuration::getAutoGenerateProxyClasses is deprecated and will not be possible in Doctrine ORM 4.0%
%Calling Doctrine\\ORM\\Configuration::(setProxyDir|getProxyDir) is deprecated and will not be possible in Doctrine ORM 4.0%
%Calling Doctrine\\ORM\\Configuration::(setAutoGenerateProxyClasses|getAutoGenerateProxyClasses) is deprecated and will not be possible in Doctrine ORM 4.0%
%Calling Doctrine\\ORM\\Configuration::setProxyNamespace is deprecated and will not be possible in Doctrine ORM 4.0%
%Since doctrine/doctrine-bundle 2.16: Not setting "doctrine.orm.enable_native_lazy_objects" to true is deprecated%
%The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0. When using ORM 3, report_fields_where_declared will always be true.%
%The "report_fields_where_declared" configuration option is deprecated and will be removed in DoctrineBundle 3.0.%
%Implicitly marking parameter \$.+ as nullable is deprecated%
%The "Doctrine\\Bundle\\DoctrineBundle\\CacheWarmer\\DoctrineMetadataCacheWarmer::doWarmUp\(\)" method will require a new "string|null \$buildDir" argument in the next major version of its parent class "Symfony\\Bundle\\FrameworkBundle\\CacheWarmer\\AbstractPhpFileCacheWarmer", not defining it is deprecated%
%Constant E_STRICT is deprecated%
%Method "ArrayAccess::(offsetExists|offsetGet|offsetSet|offsetUnset)\(\)" might add ".+" as a native return type declaration in the future. Do the same in implementation "(Doctrine\\Common\\Collections\\.+|Doctrine\\ORM\\PersistentCollection)" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "Countable::count\(\)" might add "int" as a native return type declaration in the future. Do the same in implementation "Doctrine\\Common\\Collections\\.+" now to avoid errors or add an explicit @return annotation to suppress this message%
%Method "IteratorAggregate::getIterator\(\)" might add "\\Traversable" as a native return type declaration in the future\. Do the same in implementation "Doctrine\\Common\\Collections\\.+" now to avoid errors or add an explicit @return annotation to suppress this message%
%Return type of Doctrine\\Common\\Collections\\(ArrayCollection|AbstractLazyCollection)::count\(\) should either be compatible with Countable::count\(\): int, or the \#\[\\ReturnTypeWillChange\] attribute should be used to temporarily suppress the notice%
%Return type of Doctrine\\Common\\Collections\\(ArrayCollection|AbstractLazyCollection)::getIterator\(\) should either be compatible with IteratorAggregate::getIterator\(\): Traversable, or the \#\[\\ReturnTypeWillChange\] attribute should be used to temporarily suppress the notice%
%Return type of Doctrine\\Common\\Collections\\(ArrayCollection|AbstractLazyCollection)::(offsetExists|offsetGet|offsetSet|offsetUnset)\(\$offset.*\) should either be compatible with ArrayAccess::(offsetExists|offsetGet|offsetSet|offsetUnset)\(mixed \$offset.*\): .+, or the \#\[\\ReturnTypeWillChange\] attribute should be used to temporarily suppress the notice%
19 changes: 19 additions & 0 deletions tests/config/doctrine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_sqlite
path: '%kernel.cache_dir%/test.sqlite'
types:
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
orm:
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: attribute
dir: '%kernel.project_dir%/tests/Entity'
prefix: 'Meilisearch\Bundle\Tests\Entity'
alias: App
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
framework:
test: true
secret: 67d829bf61dc5f87a73fd814e2c9f629
http_method_override: false

doctrine:
dbal:
default_connection: default
Expand All @@ -14,7 +9,6 @@ doctrine:
dummy_object_id: Meilisearch\Bundle\Tests\Dbal\Type\DummyObjectIdType
orm:
auto_generate_proxy_classes: true
report_fields_where_declared: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
Expand Down
10 changes: 0 additions & 10 deletions tests/config/config_php7.yaml → tests/config/doctrine_php7.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
framework:
test: true
secret: 67d829bf61dc5f87a73fd814e2c9f629
http_method_override: false
annotations: true
serializer:
enable_annotations: true
router:
utf8: true

doctrine:
dbal:
default_connection: default
Expand Down
6 changes: 0 additions & 6 deletions tests/config/config.yaml → tests/config/doctrine_v2.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
framework:
test: true
secret: 67d829bf61dc5f87a73fd814e2c9f629
http_method_override: false

doctrine:
dbal:
default_connection: default
Expand All @@ -15,7 +10,6 @@ doctrine:
orm:
enable_native_lazy_objects: true
auto_generate_proxy_classes: false
report_fields_where_declared: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
Expand Down
4 changes: 4 additions & 0 deletions tests/config/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
test: true
secret: 67d829bf61dc5f87a73fd814e2c9f629
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Avoid key-like test secret to silence secret scanners.

Use a clearly non-secret value or env var to prevent gitleaks noise.

Apply one of:

-framework:
-    test: true
-    secret: 67d829bf61dc5f87a73fd814e2c9f629
-    http_method_override: false
+framework:
+    test: true
+    secret: 'test_secret_value'
+    http_method_override: false

or (if you prefer env):

-    secret: 67d829bf61dc5f87a73fd814e2c9f629
+    secret: '%env(string:default::TEST_APP_SECRET)%'

Add TEST_APP_SECRET to CI env if using the second option.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
secret: 67d829bf61dc5f87a73fd814e2c9f629
secret: '%env(string:default::TEST_APP_SECRET)%'
🧰 Tools
🪛 Gitleaks (8.28.0)

[high] 3-3: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🤖 Prompt for AI Agents
In tests/config/framework.yaml at line 3 replace the key-like secret value with
a clearly non-secret placeholder or an env var reference to avoid secret
scanners; either set secret: "test-secret" (or similar obviously fake value) or
change to secret: "${TEST_APP_SECRET}" and add TEST_APP_SECRET to CI environment
variables, ensuring no real keys are committed.

http_method_override: false
Loading