getMockBuilder(Access::class)->getMock(); $user = $this->getMockBuilder(Access::class)->getMock(); $user->method('getChildren') ->willReturn(new ArrayCollection([$children])); $this->assertTrue($switchUser->isAllowedToSwitch($user, $children)); } /** * @see SwitchUser::isAllowedToSwitch() */ public function testIsNotAllowedToSwitch(): void { // Cannot mock SwitchUser because of https://github.com/sebastianbergmann/phpunit/issues/3886 $switchUser = new SwitchUser(); $children = $this->getMockBuilder(Access::class)->getMock(); $user = $this->getMockBuilder(Access::class)->getMock(); $user ->expects($this->once()) ->method('getChildren') ->willReturn(new ArrayCollection()); $this->assertFalse($switchUser->isAllowedToSwitch($user, $children)); } }