[BUGFIX] Namespace: EXT: indexed_search
authorFelix Kopp <felix-source@phorax.com>
Mon, 27 Aug 2012 15:35:43 +0000 (17:35 +0200)
committerJigal van Hemert <jigal@xs4all.nl>
Mon, 27 Aug 2012 20:33:34 +0000 (22:33 +0200)
Moves unit test case to the Tests folder and removes
the compatibility wrapper for previous test case.
Adds the namespace declaration for tx_phpunit_testcase.

Change-Id: I647e3ca873842f9c65c6d2fbab25748343792a5b
Fixes: #40275
Related: #40095
Releases: 6.0
Reviewed-on: http://review.typo3.org/14142
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
typo3/sysext/indexed_search/Tests/Unit/IndexerTest.php [new file with mode: 0644]
typo3/sysext/indexed_search/tests/Unit/IndexerTest.php [deleted file]
typo3/sysext/indexed_search/tests/tx_indexedsearch_indexerTest.php [deleted file]

diff --git a/typo3/sysext/indexed_search/Tests/Unit/IndexerTest.php b/typo3/sysext/indexed_search/Tests/Unit/IndexerTest.php
new file mode 100644 (file)
index 0000000..056d94d
--- /dev/null
@@ -0,0 +1,151 @@
+<?php
+namespace TYPO3\CMS\IndexedSearch\Tests\Unit;
+
+/**
+ * This class contains unit tests for the indexer
+ *
+ * @author Dmitry Dulepov <dmitry.dulepov@gmail.com>
+ * @author Christian Kuhn <lolli@schwarzbu.ch>
+ * @package TYPO3
+ * @subpackage tx_indexedsearch
+ */
+class IndexerTest extends \tx_phpunit_testcase {
+
+       /**
+        * Indexer instance
+        *
+        * @var \TYPO3\CMS\IndexedSearch\Indexer
+        */
+       protected $indexer;
+
+       /**
+        * A name of the temporary file
+        *
+        * @var string
+        */
+       protected $temporaryFileName = '';
+
+       /**
+        * Sets up the test
+        *
+        * @return void
+        */
+       public function setUp() {
+               $this->indexer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_indexedsearch_indexer');
+       }
+
+       /**
+        * Explicitly cleans up the indexer object to prevent any memory leaks
+        *
+        * @return void
+        */
+       public function tearDown() {
+               unset($this->indexer);
+               if ($this->temporaryFileName) {
+                       @unlink($this->temporaryFileName);
+               }
+       }
+
+       /**
+        * Checks that non-existing files are not returned
+        *
+        * @return void
+        */
+       public function testNonExistingLocalPath() {
+               $html = ('test <a href="' . md5(uniqid(''))) . '">test</a> test';
+               $result = $this->indexer->extractHyperLinks($html);
+               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
+               $this->assertEquals($result[0]['localPath'], '', 'Local path is incorrect');
+       }
+
+       /**
+        * Checks that using t3vars returns correct file
+        *
+        * @return void
+        */
+       public function testLocalPathWithT3Vars() {
+               $this->temporaryFileName = tempnam(sys_get_temp_dir(), 't3unit-');
+               $html = 'test <a href="testfile">test</a> test';
+               $savedValue = $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'];
+               $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = array(
+                       \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $this->temporaryFileName
+               );
+               $result = $this->indexer->extractHyperLinks($html);
+               $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = $savedValue;
+               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
+               $this->assertEquals($result[0]['localPath'], $this->temporaryFileName, 'Local path is incorrect');
+       }
+
+       /**
+        * Tests that a path with baseURL
+        *
+        * @return void
+        */
+       public function testLocalPathWithSiteURL() {
+               $baseURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
+               $html = ('test <a href="' . $baseURL) . 'index.php">test</a> test';
+               $result = $this->indexer->extractHyperLinks($html);
+               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
+               $this->assertEquals($result[0]['localPath'], PATH_site . 'index.php', 'Local path is incorrect');
+       }
+
+       /**
+        * Tests absolute path
+        *
+        * @return void
+        */
+       public function testRelativeLocalPath() {
+               $html = 'test <a href="index.php">test</a> test';
+               $result = $this->indexer->extractHyperLinks($html);
+               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
+               $this->assertEquals($result[0]['localPath'], PATH_site . 'index.php', 'Local path is incorrect');
+       }
+
+       /**
+        * Tests absolute path.
+        *
+        * @return void
+        */
+       public function testAbsoluteLocalPath() {
+               $path = substr(PATH_typo3, strlen(PATH_site) - 1);
+               $html = ('test <a href="' . $path) . 'index.php">test</a> test';
+               $result = $this->indexer->extractHyperLinks($html);
+               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
+               $this->assertEquals($result[0]['localPath'], PATH_typo3 . 'index.php', 'Local path is incorrect');
+       }
+
+       /**
+        * Tests that a path with the absRefPrefix returns correct result
+        *
+        * @return void
+        */
+       public function testLocalPathWithAbsRefPrefix() {
+               $absRefPrefix = '/' . md5(uniqid(''));
+               $html = ('test <a href="' . $absRefPrefix) . 'index.php">test</a> test';
+               $savedPrefix = $GLOBALS['TSFE']->config['config']['absRefPrefix'];
+               if (!($GLOBALS['TSFE'] instanceof \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController)) {
+                       $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController');
+               }
+               $GLOBALS['TSFE']->config['config']['absRefPrefix'] = $absRefPrefix;
+               $result = $this->indexer->extractHyperLinks($html);
+               $GLOBALS['TSFE']->config['config']['absRefPrefix'] = $savedPrefix;
+               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
+               $this->assertEquals($result[0]['localPath'], PATH_site . 'index.php', 'Local path is incorrect');
+       }
+
+       /**
+        * Checks that base HREF is extracted correctly
+        *
+        * @return void
+        */
+       public function textExtractBaseHref() {
+               $baseHref = 'http://example.com/';
+               $html = ('<html><head><Base Href="' . $baseHref) . '" /></head></html>';
+               $result = $this->indexer->extractHyperLinks($html);
+               $this->assertEquals($baseHref, $result, 'Incorrect base href was extracted');
+       }
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/indexed_search/tests/Unit/IndexerTest.php b/typo3/sysext/indexed_search/tests/Unit/IndexerTest.php
deleted file mode 100644 (file)
index a0aa256..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php
-namespace TYPO3\CMS\IndexedSearch\Tests\Unit;
-
-/**
- * This class contains unit tests for the indexer
- *
- * @author Dmitry Dulepov <dmitry.dulepov@gmail.com>
- * @author Christian Kuhn <lolli@schwarzbu.ch>
- * @package TYPO3
- * @subpackage tx_indexedsearch
- */
-class IndexerTest extends tx_phpunit_testcase {
-
-       /**
-        * Indexer instance
-        *
-        * @var \TYPO3\CMS\IndexedSearch\Indexer
-        */
-       protected $indexer;
-
-       /**
-        * A name of the temporary file
-        *
-        * @var string
-        */
-       protected $temporaryFileName = '';
-
-       /**
-        * Sets up the test
-        *
-        * @return void
-        */
-       public function setUp() {
-               $this->indexer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_indexedsearch_indexer');
-       }
-
-       /**
-        * Explicitly cleans up the indexer object to prevent any memory leaks
-        *
-        * @return void
-        */
-       public function tearDown() {
-               unset($this->indexer);
-               if ($this->temporaryFileName) {
-                       @unlink($this->temporaryFileName);
-               }
-       }
-
-       /**
-        * Checks that non-existing files are not returned
-        *
-        * @return void
-        */
-       public function testNonExistingLocalPath() {
-               $html = ('test <a href="' . md5(uniqid(''))) . '">test</a> test';
-               $result = $this->indexer->extractHyperLinks($html);
-               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
-               $this->assertEquals($result[0]['localPath'], '', 'Local path is incorrect');
-       }
-
-       /**
-        * Checks that using t3vars returns correct file
-        *
-        * @return void
-        */
-       public function testLocalPathWithT3Vars() {
-               $this->temporaryFileName = tempnam(sys_get_temp_dir(), 't3unit-');
-               $html = 'test <a href="testfile">test</a> test';
-               $savedValue = $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'];
-               $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = array(
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $this->temporaryFileName
-               );
-               $result = $this->indexer->extractHyperLinks($html);
-               $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = $savedValue;
-               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
-               $this->assertEquals($result[0]['localPath'], $this->temporaryFileName, 'Local path is incorrect');
-       }
-
-       /**
-        * Tests that a path with baseURL
-        *
-        * @return void
-        */
-       public function testLocalPathWithSiteURL() {
-               $baseURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
-               $html = ('test <a href="' . $baseURL) . 'index.php">test</a> test';
-               $result = $this->indexer->extractHyperLinks($html);
-               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
-               $this->assertEquals($result[0]['localPath'], PATH_site . 'index.php', 'Local path is incorrect');
-       }
-
-       /**
-        * Tests absolute path
-        *
-        * @return void
-        */
-       public function testRelativeLocalPath() {
-               $html = 'test <a href="index.php">test</a> test';
-               $result = $this->indexer->extractHyperLinks($html);
-               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
-               $this->assertEquals($result[0]['localPath'], PATH_site . 'index.php', 'Local path is incorrect');
-       }
-
-       /**
-        * Tests absolute path.
-        *
-        * @return void
-        */
-       public function testAbsoluteLocalPath() {
-               $path = substr(PATH_typo3, strlen(PATH_site) - 1);
-               $html = ('test <a href="' . $path) . 'index.php">test</a> test';
-               $result = $this->indexer->extractHyperLinks($html);
-               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
-               $this->assertEquals($result[0]['localPath'], PATH_typo3 . 'index.php', 'Local path is incorrect');
-       }
-
-       /**
-        * Tests that a path with the absRefPrefix returns correct result
-        *
-        * @return void
-        */
-       public function testLocalPathWithAbsRefPrefix() {
-               $absRefPrefix = '/' . md5(uniqid(''));
-               $html = ('test <a href="' . $absRefPrefix) . 'index.php">test</a> test';
-               $savedPrefix = $GLOBALS['TSFE']->config['config']['absRefPrefix'];
-               $GLOBALS['TSFE']->config['config']['absRefPrefix'] = $absRefPrefix;
-               $result = $this->indexer->extractHyperLinks($html);
-               $GLOBALS['TSFE']->config['config']['absRefPrefix'] = $savedPrefix;
-               $this->assertEquals(1, count($result), 'Wrong number of parsed links');
-               $this->assertEquals($result[0]['localPath'], PATH_site . 'index.php', 'Local path is incorrect');
-       }
-
-       /**
-        * Checks that base HREF is extracted correctly
-        *
-        * @return void
-        */
-       public function textExtractBaseHref() {
-               $baseHref = 'http://example.com/';
-               $html = ('<html><head><Base Href="' . $baseHref) . '" /></head></html>';
-               $result = $this->indexer->extractHyperLinks($html);
-               $this->assertEquals($baseHref, $result, 'Incorrect base href was extracted');
-       }
-
-}
-
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/indexed_search/tests/tx_indexedsearch_indexerTest.php b/typo3/sysext/indexed_search/tests/tx_indexedsearch_indexerTest.php
deleted file mode 100644 (file)
index 827675e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2010-2011 Dmitry Dulepov (dmitry.dulepov@gmail.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 \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('indexed_search', 'class.indexer.php');
-/*
- * @deprecated since 6.0, the classname tx_indexedsearch_indexerTest and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/indexed_search/Tests/Unit/IndexerTest.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('indexed_search') . 'Tests/Unit/IndexerTest.php';
-?>
\ No newline at end of file