From 28450133c8f9fc847f0a566ff89f462c32807dcc Mon Sep 17 00:00:00 2001
From: Vadim Justus <v.justus@techdivision.com>
Date: Wed, 19 Oct 2022 18:19:13 +0200
Subject: [PATCH] TDMET-5 fix integration test issues

---
 Model/Command/ApplyMediaFiles.php                     |  3 +--
 Model/Config/Parser/ParserChain.php                   |  3 +++
 Model/Config/Parser/Query/FetchMediaFilesChain.php    |  3 +++
 .../_files/test-files/content-with-images-1.html      |  6 +++---
 .../Model/PageInstaller/InstallMediaFilesTest.php     |  8 +-------
 .../_files/content/content-with-images-1.html         |  6 +++---
 Test/Integration/phpunit.gitlab.xml                   |  2 +-
 etc/di.xml                                            | 11 +++++++++++
 8 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/Model/Command/ApplyMediaFiles.php b/Model/Command/ApplyMediaFiles.php
index a636d39..763a123 100644
--- a/Model/Command/ApplyMediaFiles.php
+++ b/Model/Command/ApplyMediaFiles.php
@@ -7,7 +7,6 @@ use Firegento\ContentProvisioning\Api\Data\EntryInterface;
 use Firegento\ContentProvisioning\Api\TargetMediaDirectoryPathProviderInterface;
 use Magento\Framework\Exception\FileSystemException;
 use Magento\Framework\Filesystem\DriverInterface;
-use SplFileInfo;
 
 class ApplyMediaFiles
 {
@@ -61,7 +60,7 @@ class ApplyMediaFiles
         $targetPathname = $targetDirPath . DIRECTORY_SEPARATOR . $fileName;
 
         if ($this->fileSystemDriver->isFile($sourcePathname)
-            && $this->fileSystemDriver->isReadable($sourcePathname)()
+            && $this->fileSystemDriver->isReadable($sourcePathname)
         ) {
             $this->createDirectory($targetDirPath, $sourceDirPath, $sourcePathname);
             $this->fileSystemDriver->copy($sourcePathname, $targetPathname);
diff --git a/Model/Config/Parser/ParserChain.php b/Model/Config/Parser/ParserChain.php
index 27c6f13..b8976bf 100644
--- a/Model/Config/Parser/ParserChain.php
+++ b/Model/Config/Parser/ParserChain.php
@@ -7,6 +7,9 @@ use DOMElement;
 use Firegento\ContentProvisioning\Api\ConfigParserInterface;
 use Magento\Framework\Exception\LocalizedException;
 
+/**
+ * @api
+ */
 class ParserChain implements ConfigParserInterface
 {
     /**
diff --git a/Model/Config/Parser/Query/FetchMediaFilesChain.php b/Model/Config/Parser/Query/FetchMediaFilesChain.php
index b20834c..e5f425c 100644
--- a/Model/Config/Parser/Query/FetchMediaFilesChain.php
+++ b/Model/Config/Parser/Query/FetchMediaFilesChain.php
@@ -6,6 +6,9 @@ namespace Firegento\ContentProvisioning\Model\Config\Parser\Query;
 use Firegento\ContentProvisioning\Api\MediaFilesParserInterface;
 use Magento\Framework\Exception\LocalizedException;
 
+/**
+ * @api
+ */
 class FetchMediaFilesChain implements MediaFilesParserInterface
 {
     /**
diff --git a/Test/Integration/Model/Config/_files/test-files/content-with-images-1.html b/Test/Integration/Model/Config/_files/test-files/content-with-images-1.html
index dc3c06d..ae7f214 100644
--- a/Test/Integration/Model/Config/_files/test-files/content-with-images-1.html
+++ b/Test/Integration/Model/Config/_files/test-files/content-with-images-1.html
@@ -1,5 +1,5 @@
 <h5>Some foobar</h5>
-<p>Foobar: <a href="{{media url=&quot;image-1.png&quot;}}">Link zu einem Bilder</a></p>
+<p>Foobar: <a href="{{media url=image-1.png}}">Link zu einem Bilder</a></p>
 <p>Dummy content...</p>
-<p>Image:&nbsp;<img src="{{media url=&quot;some-test-image.png&quot;}}" alt="fooo" width="300"></p>
-<p>Image 2:&nbsp;<img src="{{media url=&quot;foobar/test.png&quot;}}" alt="" width="450" height="150"></p>
\ No newline at end of file
+<p>Image:&nbsp;<img src="{{media url=some-test-image.png}}" alt="fooo" width="300"></p>
+<p>Image 2:&nbsp;<img src="{{media url=foobar/test.png}}" alt="" width="450" height="150"></p>
\ No newline at end of file
diff --git a/Test/Integration/Model/PageInstaller/InstallMediaFilesTest.php b/Test/Integration/Model/PageInstaller/InstallMediaFilesTest.php
index bb6c6ad..8683079 100644
--- a/Test/Integration/Model/PageInstaller/InstallMediaFilesTest.php
+++ b/Test/Integration/Model/PageInstaller/InstallMediaFilesTest.php
@@ -81,13 +81,7 @@ class InstallMediaFilesTest extends TestCase
      */
     private function getChildDirectoryUrl(string $name): string
     {
-        foreach ($this->fileSystem->getChildren() as $child) {
-            if ($child->getName() === $name) {
-                return $child->url();
-            }
-        }
-
-        $this->fail('Unknown child name for virtual directory!');
+        return $this->fileSystem->getChild($name)->url();
     }
 
     protected function initEntries()
diff --git a/Test/Integration/_files/content/content-with-images-1.html b/Test/Integration/_files/content/content-with-images-1.html
index dc3c06d..ae7f214 100644
--- a/Test/Integration/_files/content/content-with-images-1.html
+++ b/Test/Integration/_files/content/content-with-images-1.html
@@ -1,5 +1,5 @@
 <h5>Some foobar</h5>
-<p>Foobar: <a href="{{media url=&quot;image-1.png&quot;}}">Link zu einem Bilder</a></p>
+<p>Foobar: <a href="{{media url=image-1.png}}">Link zu einem Bilder</a></p>
 <p>Dummy content...</p>
-<p>Image:&nbsp;<img src="{{media url=&quot;some-test-image.png&quot;}}" alt="fooo" width="300"></p>
-<p>Image 2:&nbsp;<img src="{{media url=&quot;foobar/test.png&quot;}}" alt="" width="450" height="150"></p>
\ No newline at end of file
+<p>Image:&nbsp;<img src="{{media url=some-test-image.png}}" alt="fooo" width="300"></p>
+<p>Image 2:&nbsp;<img src="{{media url=foobar/test.png}}" alt="" width="450" height="150"></p>
\ No newline at end of file
diff --git a/Test/Integration/phpunit.gitlab.xml b/Test/Integration/phpunit.gitlab.xml
index e91b10b..ed3e3ed 100644
--- a/Test/Integration/phpunit.gitlab.xml
+++ b/Test/Integration/phpunit.gitlab.xml
@@ -42,7 +42,7 @@
         <!-- Semicolon-separated 'glob' patterns, that match global XML configuration files -->
         <const name="TESTS_GLOBAL_CONFIG_DIR" value="../../../app/etc"/>
         <!-- Whether to cleanup the application before running tests or not -->
-        <const name="TESTS_CLEANUP" value="enabled"/>
+        <const name="TESTS_CLEANUP" value="disabled"/>
         <!-- Memory usage and estimated leaks thresholds -->
         <!--<const name="TESTS_MEM_USAGE_LIMIT" value="1024M"/>-->
         <const name="TESTS_MEM_LEAK_LIMIT" value=""/>
diff --git a/etc/di.xml b/etc/di.xml
index 5eab44e..3cb939c 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -105,6 +105,17 @@
         </arguments>
     </type>
 
+    <type name="Firegento\ContentProvisioning\Model\Resolver\FileContentResolver">
+        <arguments>
+            <argument name="fileSystemDriver" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
+        </arguments>
+    </type>
+    <type name="Firegento\ContentProvisioning\Model\Command\ApplyMediaFiles">
+        <arguments>
+            <argument name="fileSystemDriver" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
+        </arguments>
+    </type>
+
     <type name="Firegento\ContentProvisioning\Model\Resolver\ContentResolverProvider">
         <arguments>
             <argument name="contentResolvers" xsi:type="array">
-- 
GitLab