protected function setUp() { $repo = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Entity\\Repository\\ConfigRepository')->disableOriginalConstructor()->getMock(); $repo->expects($this->any())->method('loadSettings'); $this->om = $this->getMock('Doctrine\\Common\\Persistence\\ObjectManager'); $this->om->expects($this->any())->method('getRepository')->will($this->returnValue($repo)); $this->object = new UserScopeManager($this->om); $this->security = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface'); $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface'); $this->security->expects($this->any())->method('getToken')->will($this->returnValue($token)); $token->expects($this->any())->method('getUser')->will($this->returnValue($this->getUser())); $this->container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $this->container->expects($this->any())->method('get')->will($this->returnValueMap([['security.context', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $this->security]])); $this->object = new UserScopeManager($this->om); $this->object->setContainer($this->container); }