/**
  * This testcase is used to test that an element from an unsupported table can
  * not be created.
  *
  * @test
  * @expectedException UnexpectedValueException
  */
 public function canNotGetElementOfUnsupportedTable()
 {
     $_uid = 4711;
     $_table = 'tx_notexisting';
     $fixture = array('uid' => $_uid, 'title' => 'record');
     $daostub = new tx_languagevisibility_daocommon_stub();
     $daostub->stub_setRow($fixture, 'tx_notexisting');
     /* @var $factory tx_languagevisibility_elementFactory */
     $factory = new tx_languagevisibility_elementFactory($daostub);
     $element = $factory->getElementForTable($_table, $_uid);
     $this->assertNull($element, 'Element should be null');
 }
 public function test_getLocalVisibilitySetting_celement()
 {
     //this time data in DB is tested!
     $_table = 'tt_content';
     $_uid = 1;
     $visibility = array('0' => 'yes', '1' => t, '2' => '');
     $fixture = array('uid' => $_uid, 'tx_languagevisibility_visibility' => serialize($visibility));
     $daostub = new tx_languagevisibility_daocommon_stub();
     $daostub->stub_setRow($fixture, $_table);
     $factory = new tx_languagevisibility_elementFactory($daostub);
     //get element from factory:
     $element = $factory->getElementForTable($_table, $_uid);
     //test
     $this->assertEquals($element->getLocalVisibilitySetting('1'), 't', "t expected");
     $this->assertEquals($element->getLocalVisibilitySetting('0'), 'yes', "yes expected");
 }
 function _getContent($table, $uid)
 {
     if (!$this->_ceImport) {
         $this->_ceImport = true;
         $this->importDataSet(dirname(__FILE__) . '/fixtures/dbContentWithVisibilityTestdata.xml');
     }
     $dao = new tx_languagevisibility_daocommon();
     $factory = new tx_languagevisibility_elementFactory($dao);
     return $factory->getElementForTable($table, $uid);
 }
 /**
  * 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');
 }
 function _fixture_getNewsElementWithDefaultVisibility()
 {
     //Create the element object fixture.
     $_table = 'tt_news';
     $_uid = 99999;
     $visibility = array('0' => '-', '1' => '-', '2' => '-');
     $fixture = array('uid' => $_uid, 'tx_languagevisibility_visibility' => serialize($visibility), 'tx_languagevisibility_inheritanceflag_original' => 0, 'tx_languagevisibility_inheritanceflag_overlayed' => 0);
     $daostub = new tx_languagevisibility_daocommon_stub();
     $daostub->stub_setRow($fixture, $_table);
     $factory = new tx_languagevisibility_elementFactory($daostub);
     //get element from factory:
     $element = $factory->getElementForTable($_table, $_uid);
     return $element;
 }