Completed
Pull Request — master (#1893)
by
unknown
03:34
created

DateIndexNameProcessorTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 44
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testDateIndexName() 0 13 1
A testDateIndexNameWithNonDefaultOptions() 0 21 1
1
<?php
2
3
namespace Elastica\Test\Processor;
4
5
use Elastica\Processor\DateIndexNameProcessor;
6
use Elastica\Test\BasePipeline as BasePipelineTest;
7
8
/**
9
 * @internal
10
 */
11
class DateIndexNameProcessorTest extends BasePipelineTest
12
{
13
    /**
14
     * @group unit
15
     */
16
    public function testDateIndexName(): void
17
    {
18
        $processor = new DateIndexNameProcessor('date1', 'M');
0 ignored issues
show
Deprecated Code introduced by
The class Elastica\Processor\DateIndexNameProcessor has been deprecated with message: since version 7.1.0, use the DateIndexNameProcessor class instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
19
20
        $expected = [
21
            'date_index_name' => [
22
                'field' => 'date1',
23
                'date_rounding' => 'M',
24
            ],
25
        ];
26
27
        $this->assertEquals($expected, $processor->toArray());
28
    }
29
30
    /**
31
     * @group unit
32
     */
33
    public function testDateIndexNameWithNonDefaultOptions(): void
34
    {
35
        $processor = new DateIndexNameProcessor('date1', 'M');
0 ignored issues
show
Deprecated Code introduced by
The class Elastica\Processor\DateIndexNameProcessor has been deprecated with message: since version 7.1.0, use the DateIndexNameProcessor class instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
36
        $processor->setTimezone('Europe/Rome');
37
        $processor->setLocale('ITALIAN');
38
        $processor->setIndexNamePrefix('myindex-');
39
        $processor->setDateFormats(['dd/MM/yyyy hh:mm:ss', 'ISO8601', 'UNIX', 'UNIX_MS']);
40
41
        $expected = [
42
            'date_index_name' => [
43
                'field' => 'date1',
44
                'date_rounding' => 'M',
45
                'timezone' => 'Europe/Rome',
46
                'locale' => 'ITALIAN',
47
                'date_formats' => ['dd/MM/yyyy hh:mm:ss', 'ISO8601', 'UNIX', 'UNIX_MS'],
48
                'index_name_prefix' => 'myindex-',
49
            ],
50
        ];
51
52
        $this->assertEquals($expected, $processor->toArray());
53
    }
54
}
55