Exemple #1
0
 public function testHooks()
 {
     $subAdmin = new \OC\SubAdmin($this->userManager, $this->groupManager, $this->dbConn);
     $test = $this;
     $u = $this->users[0];
     $g = $this->groups[0];
     $count = 0;
     $subAdmin->listen('\\OC\\SubAdmin', 'postCreateSubAdmin', function ($user, $group) use($test, $u, $g, &$count) {
         $test->assertEquals($u->getUID(), $user->getUID());
         $test->assertEquals($g->getGID(), $group->getGID());
         $count++;
     });
     $subAdmin->listen('\\OC\\SubAdmin', 'postDeleteSubAdmin', function ($user, $group) use($test, $u, $g, &$count) {
         $test->assertEquals($u->getUID(), $user->getUID());
         $test->assertEquals($g->getGID(), $group->getGID());
         $count++;
     });
     $this->assertTrue($subAdmin->createSubAdmin($u, $g));
     $this->assertEquals(1, $count);
     $this->assertTrue($subAdmin->deleteSubAdmin($u, $g));
     $this->assertEquals(2, $count);
 }