Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Merge 8602e56 into ee86599
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Feb 5, 2020
2 parents ee86599 + 8602e56 commit 916fd0f
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 66 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on: [push, pull_request]
name: Lint
jobs:
doctor-rst:
name: DOCtor-RST
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: DOCtor-RST
uses: docker://oskarstark/doctor-rst
with:
args: --short
env:
DOCS_DIR: 'docs/'
30 changes: 30 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# https://github.com/actions/stale

name: "Stale"

on:
schedule:
- cron: "0 9-18 * * *"

jobs:
stale:
runs-on: "ubuntu-latest"

steps:
- name: "Close stale issues and pull requests"
uses: "actions/stale@v1.1.0"
with:
days-before-close: 7
days-before-stale: 180
repo-token: "${{ secrets.GITHUB_TOKEN }}"
exempt-issue-label: "keep"
stale-issue-label: "stale"
stale-issue-message: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
stale-pr-label: "stale"
stale-pr-message: >
This PR has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ env:
- SYMFONY_DEPRECATIONS_HELPER=max[self]=0
- TARGET=test
- UPSTREAM_URL=https://github.com/sonata-project/SonataAdminSearchBundle.git
- PHPUNIT_VERSION=7
- PHPUNIT_VERSION=8

matrix:
fast_finish: true
Expand All @@ -45,9 +45,9 @@ matrix:
- php: '7.2'
env: COMPOSER_FLAGS="--prefer-lowest"
- php: '7.3'
env: SYMFONY=3.4.*
env: SYMFONY=4.4.*
- php: '7.3'
env: SYMFONY='dev-master as 3.4.x-dev'
env: SYMFONY='dev-master as 4.4.x-dev'
- php: '7.3'
env: SONATA_ADMIN=3.*
- php: '7.3'
Expand All @@ -62,7 +62,7 @@ matrix:
- php: 7.4snapshot
- php: nightly
- env: SYMFONY_DEPRECATIONS_HELPER=0
- env: SYMFONY='dev-master as 3.4.x-dev'
- env: SYMFONY='dev-master as 4.4.x-dev'
- env: SONATA_ADMIN='dev-master as 3.x-dev'
- env: RUFLIN_ELASTICA='dev-master as 2.x-dev'

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"require-dev": {
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.1",
"symfony/phpunit-bridge": "^4.2"
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"symfony/phpunit-bridge": "^5.0"
},
"config": {
"sort-packages": true
Expand Down
32 changes: 32 additions & 0 deletions docs/.doctor-rst.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
rules:
blank_line_after_directive: ~
short_array_syntax: ~
typo: ~
replacement: ~
composer_dev_option_at_the_end: ~
yarn_dev_option_at_the_end: ~
versionadded_directive_should_have_version: ~
no_composer_req: ~
no_php_open_tag_in_code_block_php_directive: ~
blank_line_after_filepath_in_code_block: ~
no_php_prefix_before_bin_console: ~
use_deprecated_directive_instead_of_versionadded: ~
no_space_before_self_xml_closing_tag: ~
no_explicit_use_of_code_block_php: ~
ensure_order_of_code_blocks_in_configuration_block: ~
american_english: ~
valid_use_statements: ~
yaml_instead_of_yml_suffix: ~
extend_abstract_admin: ~
final_admin_class: ~
final_admin_extension_classes: ~
no_admin_yaml: ~
no_bash_prompt: ~
no_composer_phar: ~
no_inheritdoc: ~

# can be enabled when no Symfony 3.4 support anymore
#no_app_bundle: ~
#no_config_yaml: ~
#kernel_instead_of_app_kernel: ~
#no_app_console: ~
7 changes: 1 addition & 6 deletions docs/reference/createquery.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
Customizing the query used to generate the list
===============================================


You can customize the list query thanks to the ``createQuery`` method.

.. code-block:: php
<?php
You can customize the list query thanks to the ``createQuery`` method::

public function createQuery($context = 'list')
{
Expand Down
30 changes: 13 additions & 17 deletions docs/reference/filter_field_definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,21 @@ Callback
To create a custom callback filter, you just need to set the "callback" filter option
to a valid callback function. First argument of this function will be
``Sonata\AdminSearchBundle\ProxyQuery\ElasticaProxyQuery`` instance which could be
modified according to your needs.
modified according to your needs::

.. code-block:: php
<?php
namespace Sonata\NewsBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminSearchBundle\ProxyQuery\ElasticaProxyQuery;

class PostAdmin extends Admin
final class PostAdmin extends AbstractAdmin
{
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('title')
->add('name', Sonata\AdminSearchBundle\Filter\CallbackFilter::class, array(
->add('name', Sonata\AdminSearchBundle\Filter\CallbackFilter::class, [
'callback' => function (ElasticaProxyQuery $query, $alias, $field, $data) {
if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
return;
Expand All @@ -54,29 +51,28 @@ modified according to your needs.

$query->addMust($queryBuilder);
}
))
])
;
}
}

Date
^^^^

To make query on date/datetime type, you can use one of the `sonata_search_elastica_date` filter types.
For example if you have a date in the ISO 8601 date format :
To make query on date/datetime type, you can use one of the `sonata_search_elastica_date`
filter types. For example if you have a date in the ISO 8601 date format::

.. code-block:: php
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('date', Sonata\AdminSearchBundle\Filter\DateTimeFilter::class, null, 'datetime', array(
'format' => 'c'
))
->add('date', Sonata\AdminSearchBundle\Filter\DateTimeFilter::class, null, 'datetime', [
'format' => 'c',
])
;
}

The format must be a string formatted according to the `php format date`_ and be the one used to map the data in elasticsearch. If it is not the same, ElasticSearch will raise an exception ``failed to parse date field [15/05/28] Invalid format``
The format must be a string formatted according to the `php format date`_ and be the one used
to map the data in elasticsearch. If it is not the same, ElasticSearch will raise an exception
``failed to parse date field [15/05/28] Invalid format``.

.. _php format date: http://php.net/manual/en/function.date.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
namespace Sonata\AdminSearchBundle\Tests\DependencyInjection\Compiler;

use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
use Sonata\AdminSearchBundle\Builder\DatagridBuilder;
use Sonata\AdminSearchBundle\DependencyInjection\Compiler\DatagridBuilderInjectionCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class DatagridBuilderInjectionCompilerPassTest extends AbstractCompilerPassTestCase
{
public function testDatagridBuilderIsInjected()
public function testDatagridBuilderIsInjected(): void
{
$this->setParameter(
'sonata.admin.search.admin_finder_services',
Expand All @@ -32,7 +33,7 @@ public function testDatagridBuilderIsInjected()
$this->setDefinition(
'sonata.admin.search.datagrid_builder',
new Definition(
'Sonata\AdminSearchBundle\Builder\DatagridBuilder',
DatagridBuilder::class,
[
new Reference('sonata.admin.search.elastica_datagrid_builder'),
null,
Expand All @@ -47,7 +48,7 @@ public function testDatagridBuilderIsInjected()
);
}

protected function registerCompilerPass(ContainerBuilder $container)
protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new DatagridBuilderInjectionCompilerPass());
}
Expand Down
9 changes: 5 additions & 4 deletions tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
namespace Sonata\AdminSearchBundle\Tests\DependencyInjection;

use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
use PHPUnit\Framework\TestCase;
use Sonata\AdminSearchBundle\DependencyInjection\Configuration;

class ConfigurationTest
class ConfigurationTest extends TestCase
{
use ConfigurationTestCaseTrait;

public function testValidation()
public function testValidation(): void
{
$this->assertConfigurationIsInvalid(
[
Expand All @@ -33,7 +34,7 @@ public function testValidation()
);
}

public function testProcessing()
public function testProcessing(): void
{
$this->assertProcessedConfigurationEquals(
[
Expand All @@ -53,7 +54,7 @@ public function testProcessing()
);
}

protected function getConfiguration()
protected function getConfiguration(): Configuration
{
return new Configuration();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/DependencyInjection/SonataAdminSearchExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

class SonataAdminSearchExtensionTest extends AbstractExtensionTestCase
{
public function getContainerExtensions()
public function getContainerExtensions(): array
{
return [
new SonataAdminSearchExtension(),
];
}

public function testLoad()
public function testLoad(): void
{
$this->load([
'admin_finder_services' => $expectedParameterValue = [
Expand Down
11 changes: 5 additions & 6 deletions tests/Filter/BooleanFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\AdminSearchBundle\Tests\Filter;

use FOS\ElasticaBundle\Finder\TransformedFinder;
use PHPUnit\Framework\TestCase;
use Sonata\AdminSearchBundle\Filter\BooleanFilter;
use Sonata\AdminSearchBundle\ProxyQuery\ElasticaProxyQuery;
Expand All @@ -25,16 +26,14 @@ class BooleanFilterTest extends TestCase
*/
protected $proxyQuery;

public function setup()
protected function setUp(): void
{
$finder = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder')
->disableOriginalConstructor()
->getMock();
$finder = $this->createMock(TransformedFinder::class);

$this->proxyQuery = new ElasticaProxyQuery($finder);
}

public function testNoFilterSimple()
public function testNoFilterSimple(): void
{
$filter = new BooleanFilter();
$value = BooleanType::TYPE_NO;
Expand All @@ -51,7 +50,7 @@ public function testNoFilterSimple()
$this->assertSame('false', $queryArray['query']['bool']['must'][0]['term']['foo']);
}

public function testYesFilterSimple()
public function testYesFilterSimple(): void
{
$filter = new BooleanFilter();
$value = BooleanType::TYPE_YES;
Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/DateFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class DateFilterTest extends TestCase
{
public function testGetFilterTypeClass()
public function testGetFilterTypeClass(): void
{
$filter = new DateFilter();

Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/DateRangeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class DateRangeFilterTest extends TestCase
{
public function testGetFilterTypeClass()
public function testGetFilterTypeClass(): void
{
$filter = new DateRangeFilter();

Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/DateTimeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class DateTimeFilterTest extends TestCase
{
public function testGetFilterTypeClass()
public function testGetFilterTypeClass(): void
{
$filter = new DateTimeFilter();

Expand Down
2 changes: 1 addition & 1 deletion tests/Filter/DateTimeRangeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class DateTimeRangeFilterTest extends TestCase
{
public function testGetFilterTypeClass()
public function testGetFilterTypeClass(): void
{
$filter = new DateTimeRangeFilter();

Expand Down
11 changes: 5 additions & 6 deletions tests/Filter/StringFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\AdminSearchBundle\Tests\Filter;

use FOS\ElasticaBundle\Finder\TransformedFinder;
use PHPUnit\Framework\TestCase;
use Sonata\AdminSearchBundle\Filter\StringFilter;
use Sonata\AdminSearchBundle\ProxyQuery\ElasticaProxyQuery;
Expand All @@ -24,16 +25,14 @@ class StringFilterTest extends TestCase
*/
protected $proxyQuery;

public function setup()
protected function setUp(): void
{
$finder = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder')
->disableOriginalConstructor()
->getMock();
$finder = $this->createMock(TransformedFinder::class);

$this->proxyQuery = new ElasticaProxyQuery($finder);
}

public function testFilterSimple()
public function testFilterSimple(): void
{
$filter = new StringFilter();
$value = 'bar';
Expand All @@ -53,7 +52,7 @@ public function testFilterSimple()
/**
* Check if filter query with special characters can be translated into JSON.
*/
public function testFilterSpecialCharacters()
public function testFilterSpecialCharacters(): void
{
$filter = new StringFilter();
$value = 'bar \ + - && || ! ( ) { } [ ] ^ " ~ * ? : baz';
Expand Down
Loading

0 comments on commit 916fd0f

Please sign in to comment.