1616use OCA \Mail \Db \MailAccount ;
1717use OCA \Mail \Service \AccountService ;
1818use OCA \Mail \Service \AliasesService ;
19+ use OCA \Mail \Service \DelegationService ;
1920use OCP \AppFramework \Http ;
2021use OCP \IRequest ;
2122use PHPUnit \Framework \MockObject \MockObject ;
@@ -28,20 +29,23 @@ class AccountApiControllerTest extends TestCase {
2829 private IRequest &MockObject $ request ;
2930 private AccountService &MockObject $ accountService ;
3031 private AliasesService &MockObject $ aliasesService ;
32+ private DelegationService &MockObject $ delegationService ;
3133
3234 protected function setUp (): void {
3335 parent ::setUp ();
3436
3537 $ this ->request = $ this ->createMock (IRequest::class);
3638 $ this ->accountService = $ this ->createMock (AccountService::class);
3739 $ this ->aliasesService = $ this ->createMock (AliasesService::class);
40+ $ this ->delegationService = $ this ->createMock (DelegationService::class);
3841
3942 $ this ->controller = new AccountApiController (
4043 'mail ' ,
4144 $ this ->request ,
4245 self ::USER_ID ,
4346 $ this ->accountService ,
4447 $ this ->aliasesService ,
48+ $ this ->delegationService ,
4549 );
4650 }
4751
@@ -52,6 +56,7 @@ public function testListWithoutUser() {
5256 null ,
5357 $ this ->accountService ,
5458 $ this ->aliasesService ,
59+ $ this ->delegationService ,
5560 );
5661
5762 $ this ->accountService ->expects (self ::never ())
@@ -74,6 +79,10 @@ public function testList() {
7479 ->method ('findByUserId ' )
7580 ->with (self ::USER_ID )
7681 ->willReturn ([$ account ]);
82+ $ this ->accountService ->expects (self ::once ())
83+ ->method ('findDelegatedAccounts ' )
84+ ->with (self ::USER_ID )
85+ ->willReturn ([]);
7786
7887 $ alias = new Alias ();
7988 $ alias ->setId (10 );
@@ -90,6 +99,7 @@ public function testList() {
9099 [
91100 'id ' => 42 ,
92101 'email ' => 'foo@bar.com ' ,
102+ 'isDelegated ' => false ,
93103 'aliases ' => [
94104 [
95105 'id ' => 10 ,
@@ -111,6 +121,10 @@ public function testListWithAliasWithoutName() {
111121 ->method ('findByUserId ' )
112122 ->with (self ::USER_ID )
113123 ->willReturn ([$ account ]);
124+ $ this ->accountService ->expects (self ::once ())
125+ ->method ('findDelegatedAccounts ' )
126+ ->with (self ::USER_ID )
127+ ->willReturn ([]);
114128
115129 $ alias = new Alias ();
116130 $ alias ->setId (10 );
@@ -127,6 +141,7 @@ public function testListWithAliasWithoutName() {
127141 [
128142 'id ' => 42 ,
129143 'email ' => 'foo@bar.com ' ,
144+ 'isDelegated ' => false ,
130145 'aliases ' => [
131146 [
132147 'id ' => 10 ,
@@ -148,6 +163,10 @@ public function testListWithoutAliases() {
148163 ->method ('findByUserId ' )
149164 ->with (self ::USER_ID )
150165 ->willReturn ([$ account ]);
166+ $ this ->accountService ->expects (self ::once ())
167+ ->method ('findDelegatedAccounts ' )
168+ ->with (self ::USER_ID )
169+ ->willReturn ([]);
151170
152171 $ this ->aliasesService ->expects (self ::once ())
153172 ->method ('findAll ' )
@@ -160,6 +179,7 @@ public function testListWithoutAliases() {
160179 [
161180 'id ' => 42 ,
162181 'email ' => 'foo@bar.com ' ,
182+ 'isDelegated ' => false ,
163183 'aliases ' => [],
164184 ]
165185 ], $ actual ->getData ());
0 commit comments