eZ\Bundle\EzPublishCoreBundle\Tests\EventListener\DynamicSettingsListenerTest::testOnConfigScopeChange PHP Method

testOnConfigScopeChange() public method

    public function testOnConfigScopeChange()
    {
        $siteAccess = new SiteAccess('test');
        $event = new ScopeChangeEvent($siteAccess);
        $resettableServices = array('foo', 'bar.baz');
        $updateableServices = array('some_service' => array(array('someMethod', 'some_expression')), 'another_service' => array(array('someMethod', 'another_expression')));
        $this->container->expects($this->at(0))->method('initialized')->willReturn(true);
        $this->container->expects($this->at(1))->method('set')->with('foo', null);
        $this->container->expects($this->at(2))->method('initialized')->willReturn(true);
        $this->container->expects($this->at(3))->method('set')->with('bar.baz', null);
        $updateableService1 = $this->getMock('\\eZ\\Bundle\\EzPublishCoreBundle\\Tests\\EventListener\\Stubs\\FooServiceInterface');
        $dynamicSetting1 = 'foo';
        $this->container->expects($this->at(4))->method('initialized')->willReturn(true);
        $this->container->expects($this->at(5))->method('get')->with('some_service')->willReturn($updateableService1);
        $updateableService1->expects($this->once())->method('someMethod')->with($dynamicSetting1);
        $updateableService2 = $this->getMock('\\eZ\\Bundle\\EzPublishCoreBundle\\Tests\\EventListener\\Stubs\\FooServiceInterface');
        $dynamicSetting2 = array('foo' => 'bar');
        $this->container->expects($this->at(6))->method('initialized')->willReturn(true);
        $this->container->expects($this->at(7))->method('get')->with('another_service')->willReturn($updateableService2);
        $updateableService2->expects($this->once())->method('someMethod')->with($dynamicSetting2);
        $this->expressionLanguage->expects($this->exactly(count($updateableServices)))->method('evaluate')->willReturnMap(array(array('some_expression', array('container' => $this->container), $dynamicSetting1), array('another_expression', array('container' => $this->container), $dynamicSetting2)));
        $listener = new DynamicSettingsListener($resettableServices, $updateableServices, $this->expressionLanguage);
        $listener->setContainer($this->container);
        $listener->onConfigScopeChange($event);
        $this->assertSame($siteAccess, $event->getSiteAccess());
    }