@@ -94,4 +94,37 @@ public function testRefreshMetadata(): void {
9494 $ this ->assertEquals ($ file ->getId (), $ retrieved ->getFileId ());
9595 $ this ->assertEquals ('yes ' , $ retrieved ->getString ('istest ' ));
9696 }
97+
98+ public function testDropMetadataForFilesChunking (): void {
99+ $ connection = $ this ->createMock (IDBConnection::class);
100+ $ qb = $ this ->createMock (\OCP \DB \QueryBuilder \IQueryBuilder::class);
101+ $ expr = $ this ->createMock (\OCP \DB \QueryBuilder \IExpressionBuilder::class);
102+
103+ $ connection ->method ('getQueryBuilder ' )->willReturn ($ qb );
104+ $ qb ->method ('expr ' )->willReturn ($ expr );
105+ $ qb ->method ('delete ' )->willReturnSelf ();
106+ $ qb ->method ('where ' )->willReturnSelf ();
107+ $ qb ->method ('hintShardKey ' )->willReturnSelf ();
108+
109+ $ fileIds = range (1 , \OCP \DB \QueryBuilder \IQueryBuilder::MAX_IN_PARAMETERS * 2 + 1 );
110+ $ expectedChunks = array_chunk ($ fileIds , \OCP \DB \QueryBuilder \IQueryBuilder::MAX_IN_PARAMETERS );
111+ $ boundChunks = [];
112+
113+ $ qb ->expects ($ this ->exactly (count ($ expectedChunks )))
114+ ->method ('createNamedParameter ' )
115+ ->willReturnCallback (function (array $ chunk , $ type ) use (&$ boundChunks ): string {
116+ $ this ->assertSame (\OCP \DB \QueryBuilder \IQueryBuilder::PARAM_INT_ARRAY , $ type );
117+ $ boundChunks [] = $ chunk ;
118+ return ':param ' ;
119+ });
120+
121+ $ qb ->expects ($ this ->exactly (count ($ expectedChunks )))
122+ ->method ('executeStatement ' )
123+ ->willReturn (1 );
124+
125+ $ service = new MetadataRequestService ($ connection , $ this ->logger );
126+ $ service ->dropMetadataForFiles (123 , $ fileIds );
127+
128+ $ this ->assertSame ($ expectedChunks , $ boundChunks );
129+ }
97130}
0 commit comments