diff options
Diffstat (limited to 'tests/lib/Group/ManagerTest.php')
-rw-r--r-- | tests/lib/Group/ManagerTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/lib/Group/ManagerTest.php b/tests/lib/Group/ManagerTest.php index 33c2daa9476..3069f9d148b 100644 --- a/tests/lib/Group/ManagerTest.php +++ b/tests/lib/Group/ManagerTest.php @@ -191,6 +191,7 @@ class ManagerTest extends TestCase { ->method('createGroup') ->will($this->returnCallback(function () use (&$backendGroupCreated) { $backendGroupCreated = true; + return true; })); $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); @@ -200,6 +201,35 @@ class ManagerTest extends TestCase { $this->assertEquals('group1', $group->getGID()); } + public function testCreateFailure() { + /**@var \PHPUnit_Framework_MockObject_MockObject|\OC\Group\Backend $backend */ + $backendGroupCreated = false; + $backend = $this->getTestBackend( + GroupInterface::ADD_TO_GROUP | + GroupInterface::REMOVE_FROM_GOUP | + GroupInterface::COUNT_USERS | + GroupInterface::CREATE_GROUP | + GroupInterface::DELETE_GROUP | + GroupInterface::GROUP_DETAILS + ); + $backend->expects($this->any()) + ->method('groupExists') + ->with('group1') + ->willReturn(false); + $backend->expects($this->once()) + ->method('createGroup') + ->willReturn(false); + $backend->expects($this->once()) + ->method('getGroupDetails') + ->willReturn([]); + + $manager = new \OC\Group\Manager($this->userManager, $this->dispatcher, $this->logger); + $manager->addBackend($backend); + + $group = $manager->createGroup('group1'); + $this->assertEquals(null, $group); + } + public function testCreateExists() { /** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Group\Backend $backend */ $backend = $this->getTestBackend(); |