Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 956f690

Browse files
authored
PHPLIB-1338 Add tests on $size Array Query Operators (#36)
1 parent 92ecc8f commit 956f690

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

generator/config/query/size.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ arguments:
1111
name: value
1212
type:
1313
- int
14+
tests:
15+
-
16+
name: 'Query an Array by Array Length'
17+
link: 'https://www.mongodb.com/docs/manual/tutorial/query-arrays/#query-an-array-by-array-length'
18+
pipeline:
19+
-
20+
$match:
21+
tags:
22+
$size: 3

tests/Builder/Query/Pipelines.php

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Tests\Builder\Query;
6+
7+
use MongoDB\Builder\Pipeline;
8+
use MongoDB\Builder\Query;
9+
use MongoDB\Builder\Stage;
10+
use MongoDB\Tests\Builder\PipelineTestCase;
11+
12+
/**
13+
* Test $size query
14+
*/
15+
class SizeOperatorTest extends PipelineTestCase
16+
{
17+
public function testQueryAnArrayByArrayLength(): void
18+
{
19+
$pipeline = new Pipeline(
20+
Stage::match(
21+
tags: Query::size(3),
22+
),
23+
);
24+
25+
$this->assertSamePipeline(Pipelines::SizeQueryAnArrayByArrayLength, $pipeline);
26+
}
27+
}

0 commit comments

Comments
 (0)