Skip to content

Commit

Permalink
Merge pull request Smile-SA#3436 from rbayet/fix-date-histogram-agg-b…
Browse files Browse the repository at this point in the history
…uilding-unit-test

[Core] Fixing the date histo. agg builder unit test (ES8 compat.)
  • Loading branch information
rbayet authored Nov 5, 2024
2 parents bd914df + b18b0e9 commit 91174be
Showing 1 changed file with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public function testBasicAggregationBuild(): void

$this->assertArrayHasKey('date_histogram', $aggregation);
$this->assertEquals('fieldName', $aggregation['date_histogram']['field']);
$this->assertEquals('1d', $aggregation['date_histogram']['interval']);
$this->assertArrayNotHasKey('interval', $aggregation['date_histogram']);
$this->assertEquals('1d', $aggregation['date_histogram']['fixed_interval']);
$this->assertArrayNotHasKey('calendar_interval', $aggregation['date_histogram']);
$this->assertEquals(0, $aggregation['date_histogram']['min_doc_count']);
}

Expand All @@ -57,6 +59,8 @@ public function testComplexeAggregationBuild(): void
null,
null,
null,
'1d', // Deprecated.
null,
'2y',
10,
['min' => 2008, 'max' => 2050]
Expand All @@ -66,9 +70,32 @@ public function testComplexeAggregationBuild(): void

$this->assertArrayHasKey('date_histogram', $aggregation);
$this->assertEquals('fieldName', $aggregation['date_histogram']['field']);
$this->assertEquals('2y', $aggregation['date_histogram']['interval']);
$this->assertEquals('2y', $aggregation['date_histogram']['fixed_interval']);
$this->assertArrayNotHasKey('calendar_interval', $aggregation['date_histogram']);
$this->assertEquals(10, $aggregation['date_histogram']['min_doc_count']);
$this->assertEquals(['min' => 2008, 'max' => 2050], $aggregation['date_histogram']['extended_bounds']);

$bucket = new HistogramBucket(
'aggregationName',
'fieldName',
[],
[],
[],
null,
null,
null,
'1d', // Deprecated.
'1y'
);

$aggregation = $aggBuilder->buildBucket($bucket);

$this->assertArrayHasKey('date_histogram', $aggregation);
$this->assertEquals('fieldName', $aggregation['date_histogram']['field']);
$this->assertArrayNotHasKey('fixed_interval', $aggregation['date_histogram']);
$this->assertEquals('1y', $aggregation['date_histogram']['calendar_interval']);
$this->assertEquals(0, $aggregation['date_histogram']['min_doc_count']);
$this->assertArrayNotHasKey('extended_bounds', $aggregation['date_histogram']);
}

/**
Expand Down

0 comments on commit 91174be

Please sign in to comment.