currentAccessExtensionIterator = $this->createMock(CurrentAccessExtensionIterator::class); $this->extension = new CurrentAccessExtension($this->security, $this->currentAccessExtensionIterator); } public function testSupportsReturnsTrueForAccessClass() { $this->assertTrue($this->extension->supports(Access::class, null)); } public function testSupportsReturnsFalseForOtherClasses() { $this->assertFalse($this->extension->supports('OtherClass', null)); } public function testAddWhere() { $this->user->method('getOrganization')->willReturn($this->organization); $this->token->method('getUser')->willReturn($this->user); $this->security->method('getToken')->willReturn($this->token); $this->queryBuilder->method('getRootAliases')->willReturn(['a']); $this->queryBuilder->expects($this->once()) ->method('andWhere') ->with('a.organization = :current_organization') ->willReturn($this->queryBuilder); $this->queryBuilder->expects($this->once()) ->method('setParameter') ->with('current_organization', $this->organization) ->willReturn($this->queryBuilder); $this->currentAccessExtensionIterator->expects($this->once()) ->method('addWhere') ->with($this->queryBuilder, ''); $this->invokeAddWhere($this->extension, $this->queryBuilder, Access::class, null); } }