1010use OCP \IBinaryFinder ;
1111use OCP \IConfig ;
1212use OCP \IL10N ;
13- use OCP \ Server ;
13+ use PHPUnit \ Framework \ MockObject \ MockObject ;
1414use Test \TestCase ;
1515
1616class MailTest extends TestCase {
17- /** @var Mail */
18- private $ admin ;
19- /** @var IConfig */
20- private $ config ;
21- /** @var IL10N */
22- private $ l10n ;
17+
18+ private Mail $ admin ;
19+ private IConfig &MockObject $ config ;
20+ private IL10N &MockObject $ l10n ;
2321
2422 protected function setUp (): void {
2523 parent ::setUp ();
@@ -32,7 +30,22 @@ protected function setUp(): void {
3230 );
3331 }
3432
35- public function testGetForm (): void {
33+ public static function dataGetForm (): array {
34+ return [
35+ [true ],
36+ [false ],
37+ ];
38+ }
39+
40+ /** @dataProvider dataGetForm */
41+ public function testGetForm (bool $ sendmail ) {
42+ $ finder = $ this ->createMock (IBinaryFinder::class);
43+ $ finder ->expects (self ::once ())
44+ ->method ('findBinaryPath ' )
45+ ->with ('sendmail ' )
46+ ->willReturn ($ sendmail ? '/usr/bin/sendmail ' : false );
47+ $ this ->overwriteService (IBinaryFinder::class, $ finder );
48+
3649 $ this ->config
3750 ->expects ($ this ->any ())
3851 ->method ('getSystemValue ' )
@@ -53,7 +66,7 @@ public function testGetForm(): void {
5366 'settings ' ,
5467 'settings/admin/additional-mail ' ,
5568 [
56- 'sendmail_is_available ' => ( bool )Server:: get (IBinaryFinder::class)-> findBinaryPath ( ' sendmail ' ) ,
69+ 'sendmail_is_available ' => $ sendmail ,
5770 'mail_domain ' => 'mx.nextcloud.com ' ,
5871 'mail_from_address ' =>
'[email protected] ' ,
5972 'mail_smtpmode ' => 'smtp ' ,
0 commit comments