Skip to content

Commit

Permalink
Simplify markAsTimeSeries tests with granularity and bucket options
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Oct 18, 2024
1 parent 0420682 commit db758a3
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions tests/Doctrine/ODM/MongoDB/Tests/Mapping/ClassMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,6 @@ public function testEmptySearchIndexDefinition(): void
$cm->addSearchIndex(['mappings' => []]);
}

public function testDefaultTimeSeriesMapping(): void
{
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class);

self::assertNull($metadata->timeSeriesOptions);
}

public function testTimeSeriesMappingOnlyWithTimeField(): void
{
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class);
Expand Down Expand Up @@ -1024,14 +1017,6 @@ public function testTimeSeriesMappingWithMissingMetadataField(): void
$metadata->markAsTimeSeries(new ODM\TimeSeries('time', 'foo'));
}

public function testTimeSeriesMappingWithGranularity(): void
{
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class);
$metadata->markAsTimeSeries(new ODM\TimeSeries('time', granularity: Granularity::Seconds));

self::assertSame(Granularity::Seconds, $metadata->timeSeriesOptions->granularity);
}

public function testTimeSeriesMappingWithExpireAfterSeconds(): void
{
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class);
Expand All @@ -1040,30 +1025,16 @@ public function testTimeSeriesMappingWithExpireAfterSeconds(): void
self::assertSame(10, $metadata->timeSeriesOptions->expireAfterSeconds);
}

public function testTimeSeriesMappingWithBucketMaxSpanSeconds(): void
{
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class);
$metadata->markAsTimeSeries(new ODM\TimeSeries('time', bucketMaxSpanSeconds: 10));

// We don't throw for invalid settings here, e.g. bucketMaxSpanSeconds not being equal to bucketRoundingSeconds
self::assertSame(10, $metadata->timeSeriesOptions->bucketMaxSpanSeconds);
}

public function testTimeSeriesMappingWithBucketRoundingSeconds(): void
{
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class);
$metadata->markAsTimeSeries(new ODM\TimeSeries('time', bucketRoundingSeconds: 10));

// We don't throw for invalid settings here, e.g. bucketMaxSpanSeconds not being equal to bucketRoundingSeconds
self::assertSame(10, $metadata->timeSeriesOptions->bucketRoundingSeconds);
}

public function testTimeSeriesMappingWithGranularityAndBucketMaxSpanSeconds(): void
{
$metadata = $this->dm->getClassMetadata(TimeSeriesTestDocument::class);
$metadata->markAsTimeSeries(new ODM\TimeSeries('time', granularity: Granularity::Hours, bucketMaxSpanSeconds: 15, bucketRoundingSeconds: 20));

// We don't throw for invalid settings here, e.g. bucketMaxSpanSeconds not being equal to bucketRoundingSeconds
/*
* We don't throw for invalid settings here, including:
* - bucketMaxSpanSeconds not being equal to bucketRoundingSeconds
* - granularity and bucket settings applied together
*/
self::assertSame(Granularity::Hours, $metadata->timeSeriesOptions->granularity);
self::assertSame(15, $metadata->timeSeriesOptions->bucketMaxSpanSeconds);
self::assertSame(20, $metadata->timeSeriesOptions->bucketRoundingSeconds);
Expand Down

0 comments on commit db758a3

Please sign in to comment.