[!!!][TASK] Remove last usages of $GLOBALS[T3_VAR]
[Packages/TYPO3.CMS.git] / typo3 / sysext / indexed_search / Tests / Unit / IndexerTest.php
index 7694601..0e25159 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\IndexedSearch\Tests\Unit;
 
 /*
@@ -14,6 +15,7 @@ namespace TYPO3\CMS\IndexedSearch\Tests\Unit;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\IndexedSearch\Indexer;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
@@ -29,11 +31,6 @@ class IndexerTest extends UnitTestCase
     protected $resetSingletonInstances = true;
 
     /**
-     * Subject is not notice free, disable E_NOTICES
-     */
-    protected static $suppressNotices = true;
-
-    /**
      * @test
      */
     public function extractHyperLinksDoesNotReturnNonExistingLocalPath()
@@ -48,31 +45,14 @@ class IndexerTest extends UnitTestCase
     /**
      * @test
      */
-    public function extractHyperLinksReturnsCorrectFileUsingT3Vars()
-    {
-        $temporaryFileName = tempnam(PATH_site . 'typo3temp/var/tests/', 't3unit-');
-        $this->testFilesToDelete[] = $temporaryFileName;
-        $html = 'test <a href="testfile">test</a> test';
-        $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = [
-            \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $temporaryFileName,
-        ];
-        $subject = new Indexer();
-        $result = $subject->extractHyperLinks($html);
-        $this->assertEquals(1, count($result));
-        $this->assertEquals($temporaryFileName, $result[0]['localPath']);
-    }
-
-    /**
-     * @test
-     */
-    public function extractHyperLinksRecurnsCorrectPathWithBaseUrl()
+    public function extractHyperLinksReturnsCorrectPathWithBaseUrl()
     {
         $baseURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
         $html = 'test <a href="' . $baseURL . 'index.php">test</a> test';
         $subject = new Indexer();
         $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
-        $this->assertEquals(PATH_site . 'index.php', $result[0]['localPath']);
+        $this->assertEquals(Environment::getPublicPath() . '/index.php', $result[0]['localPath']);
     }
 
     /**
@@ -84,7 +64,7 @@ class IndexerTest extends UnitTestCase
         $subject = new Indexer();
         $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
-        $this->assertEquals(PATH_site . 'index.php', $result[0]['localPath']);
+        $this->assertEquals(Environment::getPublicPath() . '/index.php', $result[0]['localPath']);
     }
 
     /**
@@ -92,12 +72,11 @@ class IndexerTest extends UnitTestCase
      */
     public function extractHyperLinksFindsCorrectPathForPathWithinTypo3Directory()
     {
-        $path = substr(PATH_typo3, strlen(PATH_site) - 1);
-        $html = 'test <a href="' . $path . 'index.php">test</a> test';
+        $html = 'test <a href="typo3/index.php">test</a> test';
         $subject = new Indexer();
         $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
-        $this->assertEquals(PATH_typo3 . 'index.php', $result[0]['localPath']);
+        $this->assertEquals(Environment::getPublicPath() . '/typo3/index.php', $result[0]['localPath']);
     }
 
     /**
@@ -117,7 +96,7 @@ class IndexerTest extends UnitTestCase
         $subject = new Indexer();
         $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
-        $this->assertEquals(PATH_site . 'index.php', $result[0]['localPath']);
+        $this->assertEquals(Environment::getPublicPath() . '/index.php', $result[0]['localPath']);
     }
 
     /**