This repository was archived by the owner on Feb 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
PHPLIB-1339 Add tests on Bitwise Query Operators #37
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3935a2a
PHPLIB-1339 Add tests on Bitwise Query Operators
GromNaN 06658a0
Use the !binary yaml tag
GromNaN 540cc0c
Add comment why we use array for bit operators
GromNaN d4fcb48
Fix consistency with the doc for binary value
GromNaN bc3cb31
Fix bit query endoding to accept single int or single bin
GromNaN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MongoDB\Tests\Builder\Query; | ||
|
||
use MongoDB\BSON\Binary; | ||
use MongoDB\Builder\Pipeline; | ||
use MongoDB\Builder\Query; | ||
use MongoDB\Builder\Stage; | ||
use MongoDB\Tests\Builder\PipelineTestCase; | ||
|
||
use function base64_decode; | ||
|
||
/** | ||
* Test $bitsAllClear query | ||
*/ | ||
class BitsAllClearOperatorTest extends PipelineTestCase | ||
{ | ||
public function testBinDataBitmask(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAllClear( | ||
new Binary(base64_decode('IA==')), | ||
), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAllClearBinDataBitmask, $pipeline); | ||
} | ||
|
||
public function testBitPositionArray(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAllClear([1, 5]), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAllClearBitPositionArray, $pipeline); | ||
} | ||
|
||
public function testIntegerBitmask(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAllClear(35), | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAllClearIntegerBitmask, $pipeline); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MongoDB\Tests\Builder\Query; | ||
|
||
use MongoDB\BSON\Binary; | ||
use MongoDB\Builder\Pipeline; | ||
use MongoDB\Builder\Query; | ||
use MongoDB\Builder\Stage; | ||
use MongoDB\Tests\Builder\PipelineTestCase; | ||
GromNaN marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
use function base64_decode; | ||
|
||
/** | ||
* Test $bitsAllSet query | ||
*/ | ||
class BitsAllSetOperatorTest extends PipelineTestCase | ||
{ | ||
public function testBinDataBitmask(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAllSet( | ||
new Binary(base64_decode('MA==')), | ||
), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAllSetBinDataBitmask, $pipeline); | ||
} | ||
|
||
public function testBitPositionArray(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAllSet([1, 5]), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAllSetBitPositionArray, $pipeline); | ||
} | ||
|
||
public function testIntegerBitmask(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAllSet(50), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAllSetIntegerBitmask, $pipeline); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MongoDB\Tests\Builder\Query; | ||
|
||
use MongoDB\BSON\Binary; | ||
use MongoDB\Builder\Pipeline; | ||
use MongoDB\Builder\Query; | ||
use MongoDB\Builder\Stage; | ||
use MongoDB\Tests\Builder\PipelineTestCase; | ||
GromNaN marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
use function base64_decode; | ||
|
||
/** | ||
* Test $bitsAnyClear query | ||
*/ | ||
class BitsAnyClearOperatorTest extends PipelineTestCase | ||
{ | ||
public function testBinDataBitmask(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAnyClear( | ||
new Binary(base64_decode('MA==')), | ||
), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAnyClearBinDataBitmask, $pipeline); | ||
} | ||
|
||
public function testBitPositionArray(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAnyClear([1, 5]), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAnyClearBitPositionArray, $pipeline); | ||
} | ||
|
||
public function testIntegerBitmask(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAnyClear(35), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAnyClearIntegerBitmask, $pipeline); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MongoDB\Tests\Builder\Query; | ||
|
||
use MongoDB\BSON\Binary; | ||
use MongoDB\Builder\Pipeline; | ||
use MongoDB\Builder\Query; | ||
use MongoDB\Builder\Stage; | ||
use MongoDB\Tests\Builder\PipelineTestCase; | ||
|
||
use function base64_decode; | ||
|
||
/** | ||
* Test $bitsAnySet query | ||
*/ | ||
class BitsAnySetOperatorTest extends PipelineTestCase | ||
{ | ||
public function testBinDataBitmask(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAnySet( | ||
new Binary(base64_decode('MA==')), | ||
), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAnySetBinDataBitmask, $pipeline); | ||
} | ||
|
||
public function testBitPositionArray(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAnySet([1, 5]), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAnySetBitPositionArray, $pipeline); | ||
} | ||
|
||
public function testIntegerBitmask(): void | ||
{ | ||
$pipeline = new Pipeline( | ||
Stage::match( | ||
a: Query::bitsAnySet(35), | ||
), | ||
); | ||
|
||
$this->assertSamePipeline(Pipelines::BitsAnySetIntegerBitmask, $pipeline); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.