[FEATURE] Check table visibility support before processing. 00/26800/2
authorChetan Thapliyal <chetan.thapliyal@aoe.com>
Tue, 14 Jan 2014 10:55:24 +0000 (11:55 +0100)
committerChetan Thapliyal <nospam.ct@gmail.com>
Tue, 14 Jan 2014 12:30:21 +0000 (13:30 +0100)
Change-Id: If94369e072f2384befc7dd5b874402a03c6a6433
Reviewed-on: https://review.typo3.org/26800
Reviewed-by: Chetan Thapliyal
Tested-by: Chetan Thapliyal
12 files changed:
class.tx_languagevisibility_abstractservices.php [new file with mode: 0644]
class.tx_languagevisibility_beservices.php
class.tx_languagevisibility_feservices.php
classes/class.tx_languagevisibility_elementFactory.php
classes/class.tx_languagevisibility_visibilityService.php
ext_autoload.php
hooks/class.tx_languagevisibility_hooks_t3lib_page.php
tests/tx_element_testcase.php
tests/tx_languagevisibility_abstractservicesTestcase.php [new file with mode: 0644]
tests/tx_languagevisibility_hooks_t3lib_page_testcase.php
tests/tx_visibilityBEService_testcase.php
tests/tx_visibilityService_testcase.php

diff --git a/class.tx_languagevisibility_abstractservices.php b/class.tx_languagevisibility_abstractservices.php
new file mode 100644 (file)
index 0000000..8c8e098
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2014 AOE media (dev@aoe.com)
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+abstract class tx_languagevisibility_abstractservices {
+
+       /**
+        * Method to check if records of a given table support the language-visibility feature.
+        *
+        * @param  string $table
+        * @return boolean
+        */
+       public static function isSupportedTable($table) {
+               $tableSupportStatus = in_array($table, tx_languagevisibility_visibilityService::getSupportedTables());
+               return $tableSupportStatus;
+       }
+}
index ee68ac5..bed6cb3 100644 (file)
@@ -22,7 +22,7 @@
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
-class tx_languagevisibility_beservices {
+class tx_languagevisibility_beservices extends tx_languagevisibility_abstractservices {
 
        protected static $cache_canBeUserCopyDelete = array();
 
@@ -183,21 +183,6 @@ class tx_languagevisibility_beservices {
        }
 
        /**
-        * Method to check if records of a given table support the languagevisibility feature
-        *
-        * @param string $table
-        * @return boolean
-        */
-       public static function isSupportedTable($table) {
-               $supported = tx_languagevisibility_visibilityService::getSupportedTables();
-               if (in_array($table, $supported)) {
-                       return TRUE;
-               } else {
-                       return FALSE;
-               }
-       }
-
-       /**
         * Static service method to determine if an record has a translation in any language
         *
         * @param int $uid
index 1e06d29..315120e 100644 (file)
@@ -28,7 +28,7 @@
  *
  * Methods can be used uninstanciated
  */
-class tx_languagevisibility_feservices {
+class tx_languagevisibility_feservices extends tx_languagevisibility_abstractservices {
 
        /**
         * @param $uid
index 26778b8..d88b9e4 100644 (file)
@@ -53,6 +53,10 @@ class tx_languagevisibility_elementFactory {
         */
        public function getElementForTable($table, $uid, $overlay_ids = TRUE) {
 
+               if (!tx_languagevisibility_feservices::isSupportedTable($table)) {
+                       throw new UnexpectedValueException($table . ' not supported ', 1195039394);
+               }
+
                if (!is_numeric($uid) || (intval($uid) === 0)) {
                                // no uid => maybe NEW element in BE
                        $row = array();
@@ -64,8 +68,7 @@ class tx_languagevisibility_elementFactory {
                        }
                }
 
-               // @todo isSupported table
-               /** @var tx_languagevisibility_element $element*/
+               /** @var tx_languagevisibility_element $element */
                switch ($table) {
                        case 'pages' :
                                $element = t3lib_div::makeInstance('tx_languagevisibility_pageelement', $row);
index cd1f18a..d6a3a10 100644 (file)
  * @coauthor Timo Schmidt <schmidt@aoemedia.de>
  */
 class tx_languagevisibility_visibilityService {
+
        /**
         * @var boolean holds the state if inheritance is enabled or not
         */
        protected static $useInheritance;
 
        /**
-        * Constructor of the service, used to initialize the service with the usage
-        * of the inheritance feature.
-        *
-        * @return void
+        * @var array
+        */
+       private static $supportedTables;
+
+       /**
+        * Constructor of the service, used to initialize the service with the usage of the inheritance feature.
         */
        public function __construct() {
                if (!isset(self::$useInheritance)) {
@@ -95,24 +98,35 @@ class tx_languagevisibility_visibilityService {
        }
 
        /**
+        * Gets the tables configured with language visibility support.
+        *
         * @static
         * @return array with all supported tables
         */
        public static function getSupportedTables() {
-               $tables = array('pages', 'tt_content', 'tt_news', 'pages_language_overlay');
+               if (!isset(self::$supportedTables)) {
+                       self::$supportedTables = array('pages', 'tt_content', 'tt_news', 'pages_language_overlay');
 
-               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['getElementForTable'])
+                       if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['getElementForTable'])
                                && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['getElementForTable'])
-               ) {
-                       $tables = array_merge($tables, array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['getElementForTable']));
-               }
-               if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['recordElementSupportedTables'])
+                       ) {
+                               self::$supportedTables = array_merge(
+                                       self::$supportedTables,
+                                       array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['getElementForTable'])
+                               );
+                       }
+
+                       if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['recordElementSupportedTables'])
                                && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['recordElementSupportedTables'])
-               ) {
-                       $tables = array_merge($tables, array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['recordElementSupportedTables']));
+                       ) {
+                               self::$supportedTables = array_merge(
+                                       self::$supportedTables,
+                                       array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['recordElementSupportedTables'])
+                               );
+                       }
                }
 
-               return $tables;
+               return self::$supportedTables;
        }
 
        /**
index ba09dce..7985645 100644 (file)
@@ -2,6 +2,7 @@
 $extensionPath = t3lib_extMgm::extPath('languagevisibility');
 $extensionClassesPath = t3lib_extMgm::extPath('languagevisibility') . 'classes/';
 return array(
+       'tx_languagevisibility_abstractservices' => $extensionPath . 'class.tx_languagevisibility_abstractservices.php',
        'tx_languagevisibility_beservices' => $extensionPath . 'class.tx_languagevisibility_beservices.php',
        'tx_languagevisibility_feservices' => $extensionPath . 'class.tx_languagevisibility_feservices.php',
        'tx_languagevisibility_fieldvisibility' => $extensionPath . 'class.tx_languagevisibility_fieldvisibility.php',
index 258dea5..b9be760 100644 (file)
@@ -82,7 +82,10 @@ class tx_languagevisibility_hooks_t3lib_page implements t3lib_pageSelect_getPage
         * @return void
         */
        public function getRecordOverlay_preProcess($table, &$row, &$sys_language_content, $OLmode, t3lib_pageSelect $parent) {
-               if (! is_array($row) || ! isset($row['uid'])) {
+
+               if (!tx_languagevisibility_feservices::isSupportedTable($table)
+                       || (!is_array($row))
+                       || (!isset($row['uid']))) {
                        return;
                }
 
@@ -128,7 +131,11 @@ class tx_languagevisibility_hooks_t3lib_page implements t3lib_pageSelect_getPage
         * @return void
         */
        public function getRecordOverlay_postProcess($table, &$row, &$sys_language_content, $OLmode, t3lib_pageSelect $parent) {
-               if (! is_array($row) || ! isset($row['uid']) || $sys_language_content == 0) {
+
+               if (!tx_languagevisibility_feservices::isSupportedTable($table)
+                       || (!is_array($row))
+                       || (!isset($row['uid']))
+                       || ($sys_language_content == 0)) {
                        return;
                }
 
index 2f3acc4..1becdba 100644 (file)
@@ -52,24 +52,21 @@ class tx_element_testcase extends tx_languagevisibility_databaseTestcase {
        }
 
        public function test_hasTranslation_celement() {
-               //this time data in DB is tested!
+               $_table = 'tt_content';
+
+                       // this time data in DB is tested!
                $this->_create_fixture_ttcontentrecords();
                $this->_create_fixture_languagerecords();
-               $_uid = 9990;
-               $_table = 'tt_content';
 
                $dao = new tx_languagevisibility_daocommon();
                $factory = new tx_languagevisibility_elementFactory($dao);
 
-               //get element from factory:
-               $element = $factory->getElementForTable($_table, $_uid);
+                       // get element from factory:
+               $element = $factory->getElementForTable($_table, 9990);
 
-               //test element 210
                $this->assertTrue($element->hasTranslation('98'), 'record should have translation');
-               $this->assertTrue($element->hasTranslation('0'), 'default transla should be there always');
-
-               $element = $factory->getElementForTable($_table, '4922');
-               $this->assertFalse($element->hasTranslation('99'), 'element 4922 should not be translated!');
+               $this->assertTrue($element->hasTranslation('0'), 'default translation should always be there');
+               $this->assertFalse($element->hasTranslation('99'), 'element 9992 should not be translated!');
        }
 
        public function test_hasTranslation_normalfcelement() {
@@ -160,7 +157,6 @@ class tx_element_testcase extends tx_languagevisibility_databaseTestcase {
                $fields_values = array('uid' => 9991, 'pid' => 1, 'l18n_parent' => 9990, 'sys_language_uid' => 98, 'header' => 'test', 't3ver_oid' => '0', 't3ver_state' => '0', 'CType' => 'text', 'bodytext' => 'test_translated' );
                $GLOBALS['TYPO3_DB']->exec_DELETEquery('tt_content', 'uid=9991');
                $GLOBALS['TYPO3_DB']->exec_INSERTquery('tt_content', $fields_values);
-
        }
 
        function _create_fixture_fcecontentrecord() {
diff --git a/tests/tx_languagevisibility_abstractservicesTestcase.php b/tests/tx_languagevisibility_abstractservicesTestcase.php
new file mode 100644 (file)
index 0000000..712f2ea
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2014 AOE media (dev@aoe.com)
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+class tx_languagevisibility_abstractservicesTestcase extends tx_languagevisibility_baseTestcase {
+
+       /**
+        * Simple test to check that supported tables can be determined correctly.
+        *
+        * @test
+        */
+       public function canDetermineSupportedTables() {
+               $expectedSupportedTables = array('pages', 'pages_language_overlay', 'tt_content', 'tt_news');
+               foreach ($expectedSupportedTables as $expectedSupportedTable) {
+                       $this->assertTrue(tx_languagevisibility_abstractservices::isSupportedTable($expectedSupportedTable));
+               }
+       }
+} 
index eb22476..faeb8e8 100644 (file)
-<?php\r
-\r
-class tx_languagevisibility_hooks_t3lib_page_ttcontent_testcase extends tx_languagevisibility_databaseTtContentTestcase {\r
-\r
-       /**\r
-        * @var t3lib_pageSelect\r
-        */\r
-       protected $t3lib_page;\r
-\r
-       public function setUp() {\r
-               parent::setUp();\r
-\r
-               $this->makeSureContentElementsImported();\r
-               $this->makeSureLanguagesImported();\r
-\r
-               $this->t3lib_page = new t3lib_pageSelect();\r
-               $this->t3lib_page->init(FALSE);\r
-       }\r
-\r
-       /**\r
-        * Check the visibility of some content elements with overlay-records\r
-        *\r
-        * @test\r
-        * @dataProvider getTtContentDataSets\r
-        * @param integer $uid\r
-        * @param integer $language\r
-        * @param integer $assertUid assert that record with this uid is used as overlay. NULL means record is removed.\r
-        * @param string $comment\r
-        */\r
-       function visibility_overlay_ttcontent($uid, $language, $assertUid, $comment = '') {\r
-               if ($uid === 26 && $language === 3) {\r
-                       xdebug_break();\r
-               }\r
-               // check environment ...\r
-               if (!t3lib_extMgm::isLoaded('version')) {\r
-                       $this->markTestSkipped('Not relevant if "version" is not installed');\r
-               }\r
-\r
-               if (is_object($GLOBALS['TSFE'])) {\r
-                       $this->markTestSkipped('Please turn off the fake frontend (phpunit extension configuration) - this test won\'t work with "fake" frontends ;)');\r
-               }\r
-\r
-               // ... get original record ...\r
-               $unOverlayedRow = $this->getContentElementRow($uid);\r
-               $this->assertTrue(\r
-                       is_array($unOverlayedRow) && $unOverlayedRow['uid'] == $uid,\r
-                       sprintf('record with uid %d found', $uid)\r
-               );\r
-\r
-               // ... overlay ...\r
-               $overlayedRow = $this->t3lib_page->getRecordOverlay('tt_content', $unOverlayedRow, $language);\r
-\r
-               // ... test\r
-               if ($assertUid === NULL) {\r
-                       $this->assertEquals(\r
-                               FALSE,\r
-                               $overlayedRow,\r
-                               sprintf('record with id %d is removed in language %d', $uid, $language)\r
-                       );\r
-               } elseif (array_key_exists('_LOCALIZED_UID', $overlayedRow)) {\r
-                       $this->assertSame(\r
-                               $assertUid,\r
-                               $overlayedRow['_LOCALIZED_UID'],\r
-                               sprintf('record %d in language %d is overlaid with record %d', $uid, $language, $assertUid)\r
-                       );\r
-               } else {\r
-                       $this->assertSame(\r
-                               $assertUid,\r
-                               $overlayedRow['uid'],\r
-                               sprintf('record %d in language %d uses record %d', $uid, $language, $assertUid)\r
-                       );\r
-               }\r
-       }\r
-\r
-       public function getTtContentDataSets() {\r
-               $testDataSet = array(\r
-                       array(1,  1, '1',   '"default" without translation'),\r
-                       array(2,  1, '3',   '"default" with translation'),\r
-                       array(2,  2, '3',   '"default" with translation in fallback'),\r
-                       array(19, 1, '19',  '"forcedToYes" without translation'),\r
-                       array(20, 1, '21',  '"forcedToYes" with translation'),\r
-                       array(20, 2, '21',  '"forcedToYes" with translation in fallback'),\r
-                       array(22, 3, NULL,  '"forcedToNo" without translation'),\r
-                       array(22, 1, NULL,  '"forcedToNo" with translation'),\r
-                       array(22, 2, NULL,  '"forcedToNo" with translation in fallback'),\r
-                       array(15, 4, '16',  '"ifTranslated" with translation'),\r
-                       array(15, 5, NULL,  '"ifTranslated" with hidden translation'),\r
-                       array(24, 3, NULL,  '"ifTranslated" without translation'),\r
-                       array(24, 2, NULL,  '"ifTranslated" with translation in fallback'),\r
-                       array(26, 1, '27',  '"ifTranslatedInFallback" with translation'),\r
-                       array(26, 7, NULL,  '"ifTranslatedInFallback" without translation in any fallback'),\r
-                       array(26, 2, '27',  '"ifTranslatedInFallback" with translation in fallback'),\r
-\r
-                       // edge cases\r
-                       array(4,  1, NULL,  '"forcedToYes" in record, but "forcedToNo" set in overlay'),\r
-                       array(10, 1, NULL,  '"forcedToNo" in record, but "forcedToYes" set in overlay'),\r
-                       array(12, 1, '13',  'corrupted visibility setting in element is ignored'),\r
-               );\r
-\r
-               // set comment as key for each entry in the array (this labels the data set when running the test)\r
-               return array_combine(array_map(function($row) { return $row[3]; }, $testDataSet), $testDataSet);\r
-       }\r
-\r
-       protected function getContentElementRow($uid) {\r
-               return $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(\r
-                       '*',\r
-                       'tt_content',\r
-                       'uid = ' . intval($uid) . ' AND deleted = 0 AND hidden = 0 AND l18n_parent = 0 AND sys_language_uid IN (-1,0)'\r
-               );\r
-       }\r
-}\r
+<?php
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2014 AOE media (dev@aoe.com)
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+require_once __DIR__ . '/tx_languagevisibility_databaseTtContentTestcase.php';
+
+class tx_languagevisibility_hooks_t3lib_page_ttcontent_testcase extends tx_languagevisibility_databaseTtContentTestcase {
+
+       /**
+        * @var t3lib_pageSelect
+        */
+       protected $t3lib_page;
+
+       public function setUp() {
+               parent::setUp();
+
+               $this->makeSureContentElementsImported();
+               $this->makeSureLanguagesImported();
+
+               $this->t3lib_page = new t3lib_pageSelect();
+               $this->t3lib_page->init(FALSE);
+       }
+
+       /**
+        * Check the visibility of some content elements with overlay-records
+        *
+        * @test
+        * @dataProvider getTtContentDataSets
+        * @param integer $uid
+        * @param integer $language
+        * @param integer $assertUid assert that record with this uid is used as overlay. NULL means record is removed.
+        * @param string $comment
+        */
+       function visibility_overlay_ttcontent($uid, $language, $assertUid, $comment = '') {
+               // check environment ...
+               if (!t3lib_extMgm::isLoaded('version')) {
+                       $this->markTestSkipped('Not relevant if "version" is not installed');
+               }
+
+               if (is_object($GLOBALS['TSFE'])) {
+                       $this->markTestSkipped('Please turn off the fake frontend (phpunit extension configuration) - this test won\'t work with "fake" frontends ;)');
+               }
+
+               // ... get original record ...
+               $unOverlayedRow = $this->getContentElementRow($uid);
+               $this->assertTrue(
+                       is_array($unOverlayedRow) && $unOverlayedRow['uid'] == $uid,
+                       sprintf('record with uid %d found', $uid)
+               );
+
+               // ... overlay ...
+               $overlayedRow = $this->t3lib_page->getRecordOverlay('tt_content', $unOverlayedRow, $language);
+
+               // ... test
+               if ($assertUid === NULL) {
+                       $this->assertEquals(
+                               FALSE,
+                               $overlayedRow,
+                               sprintf('record with id %d is removed in language %d', $uid, $language)
+                       );
+               } elseif (array_key_exists('_LOCALIZED_UID', $overlayedRow)) {
+                       $this->assertSame(
+                               $assertUid,
+                               $overlayedRow['_LOCALIZED_UID'],
+                               sprintf('record %d in language %d is overlaid with record %d', $uid, $language, $assertUid)
+                       );
+               } else {
+                       $this->assertSame(
+                               $assertUid,
+                               $overlayedRow['uid'],
+                               sprintf('record %d in language %d uses record %d', $uid, $language, $assertUid)
+                       );
+               }
+       }
+
+       public function getTtContentDataSets() {
+               $testDataSet = array(
+                       array(1,  1, '1',   '"default" without translation'),
+                       array(2,  1, '3',   '"default" with translation'),
+                       array(2,  2, '3',   '"default" with translation in fallback'),
+                       array(19, 1, '19',  '"forcedToYes" without translation'),
+                       array(20, 1, '21',  '"forcedToYes" with translation'),
+                       array(20, 2, '21',  '"forcedToYes" with translation in fallback'),
+                       array(22, 3, NULL,  '"forcedToNo" without translation'),
+                       array(22, 1, NULL,  '"forcedToNo" with translation'),
+                       array(22, 2, NULL,  '"forcedToNo" with translation in fallback'),
+                       array(15, 4, '16',  '"ifTranslated" with translation'),
+                       array(15, 5, NULL,  '"ifTranslated" with hidden translation'),
+                       array(24, 3, NULL,  '"ifTranslated" without translation'),
+                       array(24, 2, NULL,  '"ifTranslated" with translation in fallback'),
+                       array(26, 1, '27',  '"ifTranslatedInFallback" with translation'),
+                       array(26, 7, NULL,  '"ifTranslatedInFallback" without translation in any fallback'),
+                       array(26, 2, '27',  '"ifTranslatedInFallback" with translation in fallback'),
+
+                       // edge cases
+                       array(4,  1, NULL,  '"forcedToYes" in record, but "forcedToNo" set in overlay'),
+                       array(10, 1, NULL,  '"forcedToNo" in record, but "forcedToYes" set in overlay'),
+                       array(12, 1, '13',  'corrupted visibility setting in element is ignored'),
+               );
+
+               // set comment as key for each entry in the array (this labels the data set when running the test)
+               return array_combine(array_map(function($row) { return $row[3]; }, $testDataSet), $testDataSet);
+       }
+
+       protected function getContentElementRow($uid) {
+               return $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
+                       '*',
+                       'tt_content',
+                       'uid = ' . intval($uid) . ' AND deleted = 0 AND hidden = 0 AND l18n_parent = 0 AND sys_language_uid IN (-1,0)'
+               );
+       }
+}
index 1302df4..6972da6 100644 (file)
 class tx_visibilityBEService_testcase extends tx_languagevisibility_databaseTestcase {
 
        /**
-        * Simple test to check that supported tables can be determined correctly
-        *
-        * @param void
-        * @return void
-        * @test
-        */
-       public function canDetermineSupportedTables() {
-               $this->assertTrue(tx_languagevisibility_beservices::isSupportedTable('tt_news'));
-               $this->assertTrue(tx_languagevisibility_beservices::isSupportedTable('pages'));
-               $this->assertTrue(tx_languagevisibility_beservices::isSupportedTable('tt_content'));
-       }
-
-       /**
         * Simple test with a tt_content element and a translation.
         * The beService should return true, because an translation for
         * the element exists.
index ca3c293..4151fad 100644 (file)
  */
 class tx_visibilityService_testcase extends tx_phpunit_testcase {
 
+       /**
+        * @test
+        */
+       public function canGetSupportedTables() {
+               $expectedSupportedTables = array('pages', 'pages_language_overlay', 'tt_content', 'tt_news');
+               $supportedTables = tx_languagevisibility_visibilityService::getSupportedTables();
+
+               $this->assertTrue(is_array($supportedTables));
+
+               foreach ($expectedSupportedTables as $expectedSupportedTable) {
+                       $this->assertContains($expectedSupportedTable, $supportedTables);
+               }
+       }
+
        public function test_visibility() {
 
                // Create the language object fixture.