diff --git a/apps/webhooks/tests/Service/PHPMongoQueryTest.php b/apps/webhooks/tests/Service/PHPMongoQueryTest.php new file mode 100644 index 00000000000..06658b718f0 --- /dev/null +++ b/apps/webhooks/tests/Service/PHPMongoQueryTest.php @@ -0,0 +1,47 @@ + [ + 'class' => NodeWrittenEvent::class, + 'node' => [ + 'id' => 23, + 'path' => '/tmp/file.txt', + ], + ], + 'user' => [ + 'uid' => 'bob', + ], + ]; + return [ + [[], [], true], + [[], $event, true], + [['event.class' => NodeWrittenEvent::class], $event, true], + [['event.class' => NodeWrittenEvent::class, 'user.uid' => 'bob'], $event, true], + [['event.node.path' => '/.txt$/'], $event, true], + [['event.node.id' => ['$gte' => 22]], $event, true], + [['event.class' => 'SomethingElse'], $event, false], + ]; + } + + /** + * @dataProvider dataExecuteQuery + */ + public function testExecuteQuery(array $query, array $document, bool $matches) { + $this->assertEquals($matches, PHPMongoQuery::executeQuery($query, $document)); + } +}