1515use OCP \Files \IRootFolder ;
1616use OCP \Files \Node ;
1717use OCP \IDBConnection ;
18- use OCP \ITagManager ;
1918use OCP \IUser ;
2019use OCP \IUserManager ;
2120use OCP \IUserSession ;
2221use OCP \Server ;
22+ use PHPUnit \Framework \MockObject \MockObject ;
2323use Psr \Log \LoggerInterface ;
2424
2525/**
2929 */
3030class TagsTest extends \Test \TestCase {
3131 protected $ objectType ;
32- /** @var IUser */
33- protected $ user ;
34- /** @var IUserSession */
35- protected $ userSession ;
36- protected $ backupGlobals = false ;
37- /** @var \OC\Tagging\TagMapper */
38- protected $ tagMapper ;
39- /** @var ITagManager */
40- protected $ tagMgr ;
41- protected IRootFolder $ rootFolder ;
32+ protected IUser &MockObject $ user ;
33+ protected IUserSession &MockObject $ userSession ;
34+ protected IUserManager &MockObject $ userManager ;
35+ protected IRootFolder &MockObject $ rootFolder ;
36+
37+ protected TagMapper $ tagMapper ;
38+ protected TagManager $ tagMgr ;
4239
4340 protected function setUp (): void {
4441 parent ::setUp ();
@@ -51,6 +48,11 @@ protected function setUp(): void {
5148 $ this ->user = $ this ->createMock (IUser::class);
5249 $ this ->user ->method ('getUID ' )
5350 ->willReturn ($ userId );
51+ $ this ->userManager = $ this ->createMock (IUserManager::class);
52+ $ this ->userManager
53+ ->expects ($ this ->any ())
54+ ->method ('get ' )
55+ ->willReturn ($ this ->user );
5456 $ this ->userSession = $ this ->createMock (IUserSession::class);
5557 $ this ->userSession
5658 ->expects ($ this ->any ())
@@ -71,7 +73,15 @@ protected function setUp(): void {
7173
7274 $ this ->objectType = $ this ->getUniqueID ('type_ ' );
7375 $ this ->tagMapper = new TagMapper (Server::get (IDBConnection::class));
74- $ this ->tagMgr = new TagManager ($ this ->tagMapper , $ this ->userSession , Server::get (IDBConnection::class), Server::get (LoggerInterface::class), Server::get (IEventDispatcher::class), $ this ->rootFolder );
76+ $ this ->tagMgr = new TagManager (
77+ $ this ->tagMapper ,
78+ $ this ->userSession ,
79+ $ this ->userManager ,
80+ Server::get (IDBConnection::class),
81+ Server::get (LoggerInterface::class),
82+ Server::get (IEventDispatcher::class),
83+ $ this ->rootFolder
84+ );
7585 }
7686
7787 protected function tearDown (): void {
@@ -88,7 +98,15 @@ public function testTagManagerWithoutUserReturnsNull(): void {
8898 ->expects ($ this ->any ())
8999 ->method ('getUser ' )
90100 ->willReturn (null );
91- $ this ->tagMgr = new TagManager ($ this ->tagMapper , $ this ->userSession , Server::get (IDBConnection::class), Server::get (LoggerInterface::class), Server::get (IEventDispatcher::class), $ this ->rootFolder );
101+ $ this ->tagMgr = new TagManager (
102+ $ this ->tagMapper ,
103+ $ this ->userSession ,
104+ $ this ->userManager ,
105+ Server::get (IDBConnection::class),
106+ Server::get (LoggerInterface::class),
107+ Server::get (IEventDispatcher::class),
108+ $ this ->rootFolder
109+ );
92110 $ this ->assertNull ($ this ->tagMgr ->load ($ this ->objectType ));
93111 }
94112
0 commit comments