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

Commit 424de32

Browse files
committed
PHPLIB-1346 Add tests on Comparison Expression Operators
1 parent 5e8b98a commit 424de32

File tree

15 files changed

+546
-0
lines changed

15 files changed

+546
-0
lines changed

generator/config/expression/cmp.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ arguments:
1515
name: expression2
1616
type:
1717
- expression
18+
tests:
19+
-
20+
name: 'Example'
21+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/cmp/#example'
22+
pipeline:
23+
-
24+
$project:
25+
item: 1
26+
qty: 1
27+
cmpTo250:
28+
$cmp:
29+
- '$qty'
30+
- 250
31+
_id: 0

generator/config/expression/eq.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ arguments:
1515
name: expression2
1616
type:
1717
- expression
18+
tests:
19+
-
20+
name: 'Example'
21+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/eq/#example'
22+
pipeline:
23+
-
24+
$project:
25+
item: 1
26+
qty: 1
27+
qtyEq250:
28+
$eq:
29+
- '$qty'
30+
- 250
31+
_id: 0

generator/config/expression/gt.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ arguments:
1515
name: expression2
1616
type:
1717
- expression
18+
tests:
19+
-
20+
name: 'Example'
21+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/gt/#example'
22+
pipeline:
23+
-
24+
$project:
25+
item: 1
26+
qty: 1
27+
qtyGt250:
28+
$gt:
29+
- '$qty'
30+
- 250
31+
_id: 0

generator/config/expression/gte.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ arguments:
1515
name: expression2
1616
type:
1717
- expression
18+
tests:
19+
-
20+
name: 'Example'
21+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/gte/#example'
22+
pipeline:
23+
-
24+
$project:
25+
item: 1
26+
qty: 1
27+
qtyGte250:
28+
$gte:
29+
- '$qty'
30+
- 250
31+
_id: 0

generator/config/expression/lt.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ arguments:
1515
name: expression2
1616
type:
1717
- expression
18+
tests:
19+
-
20+
name: 'Example'
21+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lt/#example'
22+
pipeline:
23+
-
24+
$project:
25+
item: 1
26+
qty: 1
27+
qtyLt250:
28+
$lt:
29+
- '$qty'
30+
- 250
31+
_id: 0

generator/config/expression/lte.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ arguments:
1515
name: expression2
1616
type:
1717
- expression
18+
tests:
19+
-
20+
name: 'Example'
21+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/lte/#example'
22+
pipeline:
23+
-
24+
$project:
25+
item: 1
26+
qty: 1
27+
qtyLte250:
28+
$lte:
29+
- '$qty'
30+
- 250
31+
_id: 0

generator/config/expression/ne.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,17 @@ arguments:
1515
name: expression2
1616
type:
1717
- expression
18+
tests:
19+
-
20+
name: 'Example'
21+
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/ne/#example'
22+
pipeline:
23+
-
24+
$project:
25+
item: 1
26+
qty: 1
27+
qtyNe250:
28+
$ne:
29+
- '$qty'
30+
- 250
31+
_id: 0
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Tests\Builder\Expression;
6+
7+
use MongoDB\Builder\Expression;
8+
use MongoDB\Builder\Pipeline;
9+
use MongoDB\Builder\Stage;
10+
use MongoDB\Tests\Builder\PipelineTestCase;
11+
12+
/**
13+
* Test $cmp expression
14+
*/
15+
class CmpOperatorTest extends PipelineTestCase
16+
{
17+
public function testExample(): void
18+
{
19+
$pipeline = new Pipeline(
20+
Stage::project(
21+
item: 1,
22+
qty: 1,
23+
cmpTo250: Expression::cmp(
24+
Expression::numberFieldPath('qty'),
25+
250,
26+
),
27+
_id: 0,
28+
),
29+
);
30+
31+
$this->assertSamePipeline(Pipelines::CmpExample, $pipeline);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Tests\Builder\Expression;
6+
7+
use MongoDB\Builder\Expression;
8+
use MongoDB\Builder\Pipeline;
9+
use MongoDB\Builder\Stage;
10+
use MongoDB\Tests\Builder\PipelineTestCase;
11+
12+
/**
13+
* Test $eq expression
14+
*/
15+
class EqOperatorTest extends PipelineTestCase
16+
{
17+
public function testExample(): void
18+
{
19+
$pipeline = new Pipeline(
20+
Stage::project(
21+
item: 1,
22+
qty: 1,
23+
qtyEq250: Expression::eq(
24+
Expression::numberFieldPath('qty'),
25+
250,
26+
),
27+
_id: 0,
28+
),
29+
);
30+
31+
$this->assertSamePipeline(Pipelines::EqExample, $pipeline);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Tests\Builder\Expression;
6+
7+
use MongoDB\Builder\Expression;
8+
use MongoDB\Builder\Pipeline;
9+
use MongoDB\Builder\Stage;
10+
use MongoDB\Tests\Builder\PipelineTestCase;
11+
12+
/**
13+
* Test $gt expression
14+
*/
15+
class GtOperatorTest extends PipelineTestCase
16+
{
17+
public function testExample(): void
18+
{
19+
$pipeline = new Pipeline(
20+
Stage::project(
21+
item: 1,
22+
qty: 1,
23+
qtyGt250: Expression::gt(
24+
Expression::numberFieldPath('qty'),
25+
250,
26+
),
27+
_id: 0,
28+
),
29+
);
30+
31+
$this->assertSamePipeline(Pipelines::GtExample, $pipeline);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Tests\Builder\Expression;
6+
7+
use MongoDB\Builder\Expression;
8+
use MongoDB\Builder\Pipeline;
9+
use MongoDB\Builder\Stage;
10+
use MongoDB\Tests\Builder\PipelineTestCase;
11+
12+
/**
13+
* Test $gte expression
14+
*/
15+
class GteOperatorTest extends PipelineTestCase
16+
{
17+
public function testExample(): void
18+
{
19+
$pipeline = new Pipeline(
20+
Stage::project(
21+
item: 1,
22+
qty: 1,
23+
qtyGte250: Expression::gte(
24+
Expression::numberFieldPath('qty'),
25+
250,
26+
),
27+
_id: 0,
28+
),
29+
);
30+
31+
$this->assertSamePipeline(Pipelines::GteExample, $pipeline);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Tests\Builder\Expression;
6+
7+
use MongoDB\Builder\Expression;
8+
use MongoDB\Builder\Pipeline;
9+
use MongoDB\Builder\Stage;
10+
use MongoDB\Tests\Builder\PipelineTestCase;
11+
12+
/**
13+
* Test $lt expression
14+
*/
15+
class LtOperatorTest extends PipelineTestCase
16+
{
17+
public function testExample(): void
18+
{
19+
$pipeline = new Pipeline(
20+
Stage::project(
21+
item: 1,
22+
qty: 1,
23+
qtyLt250: Expression::lt(
24+
Expression::numberFieldPath('qty'),
25+
250,
26+
),
27+
_id: 0,
28+
),
29+
);
30+
31+
$this->assertSamePipeline(Pipelines::LtExample, $pipeline);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Tests\Builder\Expression;
6+
7+
use MongoDB\Builder\Expression;
8+
use MongoDB\Builder\Pipeline;
9+
use MongoDB\Builder\Stage;
10+
use MongoDB\Tests\Builder\PipelineTestCase;
11+
12+
/**
13+
* Test $lte expression
14+
*/
15+
class LteOperatorTest extends PipelineTestCase
16+
{
17+
public function testExample(): void
18+
{
19+
$pipeline = new Pipeline(
20+
Stage::project(
21+
item: 1,
22+
qty: 1,
23+
qtyLte250: Expression::lte(
24+
Expression::numberFieldPath('qty'),
25+
250,
26+
),
27+
_id: 0,
28+
),
29+
);
30+
31+
$this->assertSamePipeline(Pipelines::LteExample, $pipeline);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace MongoDB\Tests\Builder\Expression;
6+
7+
use MongoDB\Builder\Expression;
8+
use MongoDB\Builder\Pipeline;
9+
use MongoDB\Builder\Stage;
10+
use MongoDB\Tests\Builder\PipelineTestCase;
11+
12+
/**
13+
* Test $ne expression
14+
*/
15+
class NeOperatorTest extends PipelineTestCase
16+
{
17+
public function testExample(): void
18+
{
19+
$pipeline = new Pipeline(
20+
Stage::project(
21+
item: 1,
22+
qty: 1,
23+
qtyNe250: Expression::ne(
24+
Expression::numberFieldPath('qty'),
25+
250,
26+
),
27+
_id: 0,
28+
),
29+
);
30+
31+
$this->assertSamePipeline(Pipelines::NeExample, $pipeline);
32+
}
33+
}

0 commit comments

Comments
 (0)