-
Couldn't load subscription status.
- Fork 13
- Update MongoDB library to v2.1 and adjust Composer dependency #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| use EmagTechLabs\MessengerMongoBundle\Tests\Unit\Fixtures\HelloMessage; | ||
| use MongoDB\BSON\ObjectId; | ||
| use MongoDB\Collection; | ||
| use MongoDB\Driver\CursorInterface; | ||
| use MongoDB\InsertOneResult; | ||
| use PHPUnit\Framework\Attributes\Test; | ||
| use PHPUnit\Framework\TestCase; | ||
|
|
@@ -128,11 +129,11 @@ public function itShouldListAllMessages(): void | |
|
|
||
| $collection = $this->createMock(Collection::class); | ||
| $collection->method('find') | ||
| ->willReturn([ | ||
| ->willReturn($this->createCursor([ | ||
| $this->createDocument(), | ||
| $this->createDocument(), | ||
| $this->createDocument(), | ||
| ]); | ||
| ])); | ||
|
|
||
| $transport = new MongoTransport( | ||
| $collection, | ||
|
|
@@ -290,4 +291,76 @@ private function createSerializer(): SerializerInterface | |
| { | ||
| return new Serializer(); | ||
| } | ||
|
|
||
| /** | ||
| * Zwraca prosty kursor zgodny z MongoDB\Driver\CursorInterface, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't forget to remove the comments |
||
| * który iteruje po przekazanej tablicy dokumentów. | ||
| * | ||
| * @param array<int, array<string, mixed>> $documents | ||
| */ | ||
| private function createCursor(array $documents): \MongoDB\Driver\CursorInterface | ||
| { | ||
| return new class($documents) implements \MongoDB\Driver\CursorInterface | ||
| { | ||
| private array $data; | ||
| private int $position = 0; | ||
|
|
||
| public function __construct(array $data) | ||
| { | ||
| $this->data = array_values($data); | ||
| } | ||
|
|
||
| // Iterator | ||
| public function current(): array|null|object | ||
| { | ||
| return $this->data[$this->position]; | ||
| } | ||
|
|
||
| public function key(): int | ||
| { | ||
| return $this->position; | ||
| } | ||
|
|
||
| public function next(): void | ||
| { | ||
| $this->position++; | ||
| } | ||
|
|
||
| public function rewind(): void | ||
| { | ||
| $this->position = 0; | ||
| } | ||
|
|
||
| public function valid(): bool | ||
| { | ||
| return array_key_exists($this->position, $this->data); | ||
| } | ||
|
|
||
| // CursorInterface | ||
| public function toArray(): array | ||
| { | ||
| return $this->data; | ||
| } | ||
|
|
||
| public function isDead(): bool | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| public function setTypeMap(array $typemap): void | ||
| { | ||
| // NOP – niepotrzebne w testach | ||
| } | ||
|
|
||
| public function getId(): \MongoDB\BSON\Int64 | ||
| { | ||
| throw new \RuntimeException('Not implemented in test cursor.'); | ||
| } | ||
|
|
||
| public function getServer(): \MongoDB\Driver\Server | ||
| { | ||
| throw new \RuntimeException('Not implemented in test cursor.'); | ||
| } | ||
| }; | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ListableReceiverInterface is defined with
iterable. Why not keepingiterable?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8.2.0 The type of iterator has been widened from Traversable to Traversable|array.
Before 8.2 should be \Traversable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MongoTransportTestuses$collection = iterator_to_array($transport->all(2));There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still i don't get why MongoTransport should not respect the interface it implements.