/**
  * We have the same situation as before but in this
  * testcase we test the visibility of page c and change
  * the pid afterward. Because the visibility is forced
  * to no by inheritance, it should normaly be visible,
  * but the result of the visibility is chached in
  * that situation and the visibility will only change afterwards
  * when the cache was flushed.
  *
  * @param void
  * @return void
  * @author Timo Schmidt <*****@*****.**>
  * @test
  */
 public function changeOfPidDoesNotInfluenceCachedResult()
 {
     $cacheManager = tx_languagevisibility_cacheManager::getInstance();
     $isCacheEnabled = $cacheManager->isCacheEnabled();
     $this->assertTrue($isCacheEnabled, 'Cache needs to be enabled to perform this test');
     $this->importDataSet(dirname(__FILE__) . '/fixtures/canDetermineInheritedVisibility.xml');
     $fixtureLanguageRow = array('uid' => 1, 'tx_languagevisibility_defaultvisibility' => 't');
     $fixtureLanguage = new tx_languagevisibility_language();
     $fixtureLanguage->setData($fixtureLanguageRow);
     $dao = new tx_languagevisibility_daocommon();
     $elementFactory = new tx_languagevisibility_elementFactory($dao);
     $fixtureElement = $elementFactory->getElementForTable('pages', 3);
     $visibilityService = new tx_languagevisibility_visibilityService();
     $visibilityResult = true;
     $visibilityResult = $visibilityService->isVisible($fixtureLanguage, $fixtureElement);
     $this->assertFalse($visibilityResult, 'The element should not be visibile because of the inherited force to no setting');
     $db = $GLOBALS['TYPO3_DB'];
     /* @var  $db t3lib_db */
     $db->exec_UPDATEquery('pages', 'pid=2', array('pid' => 0));
     $visibilityResult = $visibilityService->isVisible($fixtureLanguage, $fixtureElement);
     $this->assertFalse($visibilityResult, 'The element should not still not be visible because the visibility result is cached');
     tx_languagevisibility_cacheManager::getInstance()->flushAllCaches();
     $visibilityResult = $visibilityService->isVisible($fixtureLanguage, $fixtureElement);
     $this->assertTrue($visibilityResult, 'Now the element should be visible because the cache was flushed');
 }
 /**
  * The inheritance of the languagevisibility is controlled by a visibility flag
  *
  * @test
  */
 public function overlayOverwritesInheritingVisibilityOfPageElements()
 {
     $this->importDataSet(dirname(__FILE__) . '/fixtures/overlayOverwritesInheritingVisibilityOfPageElements.xml');
     $language = $this->_getLang(1);
     $service = new tx_languagevisibility_visibilityService();
     $service->setUseInheritance();
     $dao = new tx_languagevisibility_daocommon();
     $factory = new tx_languagevisibility_elementFactory($dao);
     $element = $factory->getElementForTable('pages', 6);
     $visibilityResult = $service->isVisible($language, $element);
     $this->assertFalse($visibilityResult, 'element should be invisible because overlay overwrites inheriting visibility on page 5');
     $element = $factory->getElementForTable('pages', 7);
     $visibilityResult = $service->isVisible($language, $element);
     $this->assertFalse($visibilityResult, 'element should be invisible because overlay overwrites inheriting visibility on page 5');
 }