Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.
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
18 changes: 15 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ jobs:
working_directory: ~/project
steps:
- checkout

- run:
name: Install PHPUnit
command: |
composer require phpunit/phpunit:7.*

- run:
name: Run tests / Symfony 4^3
command: |
composer update -n --prefer-dist --prefer-stable --no-suggest
php vendor/bin/phpunit

- run:
name: Run tests
name: Run tests / Symfony 5^0
command: |
composer install -n --prefer-dist --no-suggest
composer test
composer update -n --prefer-dist --no-suggest
php vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .php_cs.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"php":"7.3.9-1+ubuntu18.04.1+deb.sury.org+1","version":"2.16.0:v2.16.0#ceaff36bee1ed3f1bbbedca36d2528c0826c336d","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"single_line":true},"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":["method"]},"concat_space":true,"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"magic_method_casing":true,"native_function_casing":true,"native_function_type_declaration_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":true,"no_unneeded_final_method":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_trait_insert_per_statement":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true},"hashes":{"Tests\/Functional\/AService.php":3371820063,"Tests\/Functional\/DependencyInjection\/EnableCommandsTest.php":1794882875,"Tests\/Functional\/DependencyInjection\/CompilerPass\/InMemoryRepositoryCompilerPassTest.php":3620326332,"Tests\/Functional\/DependencyInjection\/CompilerPass\/TransformersCompilerPassTest.php":2286676217,"Tests\/Functional\/DependencyInjection\/CompilerPass\/HttpRepositoryCompilerPassTest.php":3050954938,"Tests\/Functional\/DependencyInjection\/ApisearchConfigurationTest.php":271608124,"Tests\/Functional\/DependencyInjection\/DisableCommandsTest.php":2271614667,"Tests\/Functional\/ApisearchBundleFunctionalTest.php":1563748362,"Tests\/Functional\/ProductWriteTransformer.php":2899478219,"Tests\/Functional\/ProductBothTransformer.php":479133393,"Tests\/Functional\/Command\/PrintIndicesCommandTest.php":481741707,"Tests\/Functional\/Command\/QueryCommandTest.php":2580406218,"Tests\/Functional\/Command\/AddDeleteTokensCommandTest.php":1868952970,"Tests\/Functional\/Command\/IndexCommandTest.php":4092266881,"Tests\/Functional\/ProductReadTransformer.php":1717369761,"Tests\/Functional\/AutowiringTest.php":1216361311,"DependencyInjection\/ApisearchExtension.php":4206190540,"DependencyInjection\/CompilerPass\/ReadTransformerCompilerPass.php":3948110591,"DependencyInjection\/CompilerPass\/ExporterCompilerPass.php":857546720,"DependencyInjection\/CompilerPass\/WriteTransformerCompilerPass.php":2530587380,"DependencyInjection\/CompilerPass\/RepositoryCompilerPass.php":3605104821,"DependencyInjection\/ApisearchConfiguration.php":1136730770,"Twig\/UrlBuilderExtension.php":1095204211,"Twig\/AggregationTranslationExtension.php":257790318,"Twig\/MethodAccessorExtension.php":2939807874,"Command\/ApisearchCommand.php":3928891909,"Command\/AddTokenCommand.php":3051589506,"Command\/WithRepositoryBucketCommand.php":1083077272,"Command\/DeleteTokensCommand.php":877678679,"Command\/ImportIndexCommand.php":3607079391,"Command\/ApisearchFormattedCommand.php":3862548494,"Command\/PrintTokensCommand.php":3348297778,"Command\/DeleteIndexCommand.php":1546190123,"Command\/DeleteTokenCommand.php":3627377100,"Command\/QueryCommand.php":2332984996,"Command\/WithAppRepositoryBucketCommand.php":759489361,"Command\/PrintIndicesCommand.php":885255525,"Command\/ResetIndexCommand.php":4125855051,"Command\/ConfigureIndexCommand.php":2323095110,"Command\/CreateIndexCommand.php":435275942,"Command\/ExportIndexCommand.php":3253784633,"Translator\/AggregationTranslator.php":3711919960,"ApisearchBundle.php":4293551145}}
{"php":"7.3.11-1+ubuntu18.04.1+deb.sury.org+1","version":"2.16.0:v2.16.0#ceaff36bee1ed3f1bbbedca36d2528c0826c336d","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":{"allow_single_line_closure":true},"class_definition":{"single_line":true},"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"binary_operator_spaces":true,"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":["method"]},"concat_space":true,"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"magic_method_casing":true,"native_function_casing":true,"native_function_type_declaration_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":true,"no_unneeded_final_method":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_trait_insert_per_statement":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true},"hashes":{"\/tmp\/phpcsfixer_temp.tmp2\/Drift\/AsyncTestClient.php":2013804296,"\/tmp\/phpcsfixer_temp.tmp4\/Drift\/AsyncTestClient.php":2230888305}}
1 change: 0 additions & 1 deletion ApisearchBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function getContainerExtension()
public static function getBundleDependencies(KernelInterface $kernel): array
{
return [
BaseBundle::class,
FrameworkBundle::class,
];
}
Expand Down
2 changes: 0 additions & 2 deletions DependencyInjection/CompilerPass/ExporterCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

namespace Apisearch\DependencyInjection\CompilerPass;

use Mmoreram\BaseBundle\CompilerPass\TagCompilerPass;

/**
* Class ExporterCompilerPass.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

namespace Apisearch\DependencyInjection\CompilerPass;

use Mmoreram\BaseBundle\CompilerPass\TagCompilerPass;

/**
* Class ReadTransformerCompilerPass.
*/
Expand Down
81 changes: 81 additions & 0 deletions DependencyInjection/CompilerPass/TagCompilerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/*
* This file is part of the BaseBundle for Symfony2.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Feel free to edit as you please, and have fun.
*
* @author Marc Morera <yuhu@mmoreram.com>
*/

declare(strict_types=1);

namespace Apisearch\DependencyInjection\CompilerPass;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* Class TagCompilerPass.
*/
abstract class TagCompilerPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait;

/**
* You can modify the container here before it is dumped to PHP code.
*
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
if (!$container->has($this->getCollectorServiceName())) {
return;
}

$definition = $container->findDefinition(
$this->getCollectorServiceName()
);

$taggedServices = $this->findAndSortTaggedServices(
$this->getTagName(),
$container
);

/*
* Per each service, add a new method call reference
*/
foreach ($taggedServices as $service) {
$definition->addMethodCall(
$this->getCollectorMethodName(),
[$service]
);
}
}

/**
* Get collector service name.
*
* @return string Collector service name
*/
abstract public function getCollectorServiceName(): string;

/**
* Get collector method name.
*
* @return string Collector method name
*/
abstract public function getCollectorMethodName(): string;

/**
* Get tag name.
*
* @return string Tag name
*/
abstract public function getTagName(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

namespace Apisearch\DependencyInjection\CompilerPass;

use Mmoreram\BaseBundle\CompilerPass\TagCompilerPass;

/**
* Class WriteTransformerCompilerPass.
*/
Expand Down
122 changes: 122 additions & 0 deletions Drift/AsyncTestClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

/*
* This file is part of the Apisearch PHP Client.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Feel free to edit as you please, and have fun.
*
* @author Marc Morera <yuhu@mmoreram.com>
*/

declare(strict_types=1);

namespace Apisearch\Drift;

use Apisearch\Http\Client;
use Apisearch\Http\HttpClient;
use Apisearch\Http\RetryMap;
use Clue\React\Block;
use Drift\HttpKernel\AsyncKernel;
use Symfony\Component\HttpFoundation\Request;

/**
* Class AsyncTestClient.
*/
class AsyncTestClient extends Client implements HttpClient
{
/**
* @var AsyncKernel
*
* Async kernel
*/
private $kernel;

/**
* TestClient constructor.
*
* @param AsyncKernel $kernel
* @param string $version
* @param RetryMap $retryMap
*/
public function __construct(
AsyncKernel $kernel,
string $version,
RetryMap $retryMap
) {
$this->kernel = $kernel;

parent::__construct(
$version,
$retryMap
);
}

/**
* Get a response given some parameters.
* Return an array with the status code and the body.
*
* @param string $url
* @param string $method
* @param array $query
* @param array $body
* @param array $server
*
* @return array
*/
public function get(
string $url,
string $method,
array $query = [],
array $body = [],
array $server = []
): array {
$method = trim(strtolower($method));
$requestParts = $this->buildRequestParts(
$url,
$query,
$body,
$server
);

$headersFormatted = [];
foreach ($server as $key => $value) {
$headersFormatted['HTTP_'.str_replace('-', '_', $key)] = $value;
}

$request = new Request(
array_map('urldecode', $query),
[],
[],
[],
[],
array_merge($headersFormatted, [
'CONTENT_TYPE' => 'application/json',
'HTTP_REFERER' => 'http://localhost',
]),
json_encode($requestParts->getParameters()['json'])
);

$request->setMethod($method);
$request->server->set('REQUEST_URI', $requestParts->getUrl());

$promise = $this
->kernel
->handleAsync($request);

$response = Block\await(
$promise,
$this
->kernel
->getContainer()
->get('reactphp.event_loop')
);

return [
'code' => $response->getStatusCode(),
'body' => json_decode($response->getContent(), true),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ protected static function getKernel(): KernelInterface
public function testBothTransormers()
{
// No error means that the transformers have been properly built
$this->assertTrue(true);
}
}
30 changes: 8 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,23 @@
],
"require": {
"php": ">=7.1",
"symfony/framework-bundle": "^3.0|^4.0",
"symfony/http-kernel": "^3.0|^4.0",
"symfony/stopwatch": "^3.0|^4.0",
"symfony/console": "^3.0|^4.0",
"symfony/framework-bundle": "^3.0|^4.0|^5.0",
"symfony/http-kernel": "^3.0|^4.0|^5.0",
"symfony/stopwatch": "^3.0|^4.0|^5.0",
"symfony/console": "^3.0|^4.0|^5.0",
"ramsey/uuid": "^3.7.1",
"mmoreram/base-bundle": "^1.0",
"mmoreram/base-bundle": "^2.0.0",
"apisearch-io/php-client": "dev-master"
},
"suggested": {
"twig/twig": "In case you use Twig engine",
"symfony/translator": "^3.0|^4.0 in case you use Macros translations"
},
"require-dev": {
"phpunit/phpunit": "^5.6.5",
"mmoreram/php-formatter": "^1.3.1",
"friendsofphp/php-cs-fixer": "^2.5.0",
"mmoreram/symfony-bundle-dependencies": "^2.1",
"symfony/browser-kit": "^3.4|^4.0"
"drift/http-kernel": "dev-master@dev",
"symfony/browser-kit": "^3.4|^4.0|^5.0"
},
"autoload": {
"psr-4": {
"Apisearch\\": ""
}
},
"scripts": {
"fix-code": [
"vendor/bin/php-cs-fixer fix --config=.php_cs",
"vendor/bin/php-formatter f:h:f . --exclude=vendor --exclude=var",
"vendor/bin/php-formatter f:s:f . --exclude=vendor --exclude=var",
"vendor/bin/php-formatter f:u:s . --exclude=vendor --exclude=var"
],
"test": "vendor/bin/phpunit"
}
"minimum-stability": "dev"
}
Loading