public function testSiteAccessConfiguration()
{
// Injecting needed config parsers.
$refExtension = new ReflectionObject($this->extension);
$refMethod = $refExtension->getMethod('getMainConfigParser');
$refMethod->setAccessible(true);
$refMethod->invoke($this->extension);
$refParser = $refExtension->getProperty('mainConfigParser');
$refParser->setAccessible(true);
/** @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigParser $parser */
$parser = $refParser->getValue($this->extension);
$parser->setConfigParsers(array(new Common(), new Content()));
$this->load($this->siteaccessConfig);
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.list', $this->siteaccessConfig['siteaccess']['list']);
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.default', $this->siteaccessConfig['siteaccess']['default_siteaccess']);
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.groups', $this->siteaccessConfig['siteaccess']['groups']);
$expectedMatchingConfig = array();
foreach ($this->siteaccessConfig['siteaccess']['match'] as $key => $val) {
// Value is expected to always be an array (transformed by semantic configuration parser).
$expectedMatchingConfig[$key] = is_array($val) ? $val : array('value' => $val);
}
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.match_config', $expectedMatchingConfig);
$groupsBySiteaccess = array();
foreach ($this->siteaccessConfig['siteaccess']['groups'] as $groupName => $groupMembers) {
foreach ($groupMembers as $member) {
if (!isset($groupsBySiteaccess[$member])) {
$groupsBySiteaccess[$member] = array();
}
$groupsBySiteaccess[$member][] = $groupName;
}
}
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.groups_by_siteaccess', $groupsBySiteaccess);
$relatedSiteAccesses = array('ezdemo_site', 'eng', 'fre', 'ezdemo_site_admin');
$this->assertContainerBuilderHasParameter('ezpublish.siteaccess.relation_map', array('' => array(2 => $relatedSiteAccesses)));
$this->assertContainerBuilderHasParameter('ezsettings.ezdemo_site.related_siteaccesses', $relatedSiteAccesses);
$this->assertContainerBuilderHasParameter('ezsettings.eng.related_siteaccesses', $relatedSiteAccesses);
$this->assertContainerBuilderHasParameter('ezsettings.fre.related_siteaccesses', $relatedSiteAccesses);
}