@@ -85,6 +85,24 @@ public function testNullInlineKeyboardIsNotEncodedAsJsonNullString(): void
8585 $ this ->assertNotSame ('null ' , $ params ['inlineKeyboardMarkup ' ]);
8686 }
8787
88+ /**
89+ * @return iterable<string, array{?string, ?string}>
90+ */
91+ public static function invalidFileParamsProvider (): iterable
92+ {
93+ yield 'both null ' => [null , null ];
94+ yield 'both provided ' => ['abc ' , '/tmp/file.txt ' ];
95+ }
96+
97+ #[DataProvider('invalidFileParamsProvider ' )]
98+ public function testSendFileThrowsOnInvalidFileParams (?string $ fileId , ?string $ filePath ): void
99+ {
100+ $ this ->expectException (\InvalidArgumentException::class);
101+ $ this ->expectExceptionMessage ('Exactly one of fileId or filePath must be provided ' );
102+
103+ $ this ->api ->sendFile (chatId: 'chat1 ' , fileId: $ fileId , filePath: $ filePath );
104+ }
105+
88106 public function testSendFileWithFileIdUsesGet (): void
89107 {
90108 $ this ->api ->sendFile (chatId: 'chat1 ' , fileId: 'abc ' );
@@ -114,6 +132,15 @@ public function testSendFileWithCaption(): void
114132 $ this ->assertSame ('my file ' , $ params ['caption ' ]);
115133 }
116134
135+ #[DataProvider('invalidFileParamsProvider ' )]
136+ public function testSendVoiceThrowsOnInvalidFileParams (?string $ fileId , ?string $ filePath ): void
137+ {
138+ $ this ->expectException (\InvalidArgumentException::class);
139+ $ this ->expectExceptionMessage ('Exactly one of fileId or filePath must be provided ' );
140+
141+ $ this ->api ->sendVoice (chatId: 'chat1 ' , fileId: $ fileId , filePath: $ filePath );
142+ }
143+
117144 public function testSendVoiceWithFileIdUsesGet (): void
118145 {
119146 $ this ->api ->sendVoice (chatId: 'chat1 ' , fileId: 'voice1 ' );
0 commit comments