浏览代码

Merge branch 'hotfix/fix_unit_tests' into develop

Olivier Massot 6 月之前
父节点
当前提交
0e40ae24c7

+ 2 - 2
src/Service/Dolibarr/DolibarrApiService.php

@@ -90,7 +90,7 @@ class DolibarrApiService extends ApiRequestService
                     'sortfield' => 'datef',
                     'sortorder' => 'DESC',
                     'limit' => 5,
-                    'sqlfilters' => "(fk_soc:=:$socId) and (fk_statut:!=:0)"
+                    'sqlfilters' => "(fk_soc:=:$socId) and (fk_statut:!=:0)",
                 ]);
         } catch (HttpException $e) {
             if ($e->getStatusCode() === 404) {
@@ -117,7 +117,7 @@ class DolibarrApiService extends ApiRequestService
                     'sortfield' => 't.date_valid',
                     'sortorder' => 'DESC',
                     'limit' => 1,
-                    'sqlfilters' => 'fk_soc:=:'.$socId
+                    'sqlfilters' => 'fk_soc:=:'.$socId,
                 ]
             );
         } catch (HttpException $e) {

+ 1 - 3
src/Service/OnChange/Core/OnFileChange.php

@@ -15,12 +15,10 @@ use Liip\ImagineBundle\Imagine\Cache\CacheManager;
 class OnFileChange extends OnChangeDefault
 {
     public function __construct(
-        protected readonly CacheManager $cacheManager
+        protected readonly CacheManager $cacheManager,
     ) {
-
     }
 
-
     public function beforeChange(mixed $file, OnChangeContext $context): void
     {
         if ($context->previousData() && $context->previousData()->getConfig() !== $file->getConfig()) {

+ 2 - 2
src/State/Provider/Core/ImageProvider.php

@@ -40,8 +40,8 @@ final class ImageProvider implements ProviderInterface
         }
 
         $uncropped =
-            isset($context['filters']['uncropped']) &&
-            ($context['filters']['uncropped'] === '1' || $context['filters']['uncropped'] === 'true');
+            isset($context['filters']['uncropped'])
+            && ($context['filters']['uncropped'] === '1' || $context['filters']['uncropped'] === 'true');
 
         return $this->getImage($uriVariables['fileId'], $uriVariables['size'], $uncropped);
     }

+ 3 - 3
tests/Unit/Service/Dolibarr/DolibarrApiServiceTest.php

@@ -172,7 +172,7 @@ class DolibarrApiServiceTest extends TestCase
         $dolibarrApiService
             ->expects(self::once())
             ->method('getJsonContent')
-            ->with('invoices', ['sortfield' => 'datef', 'sortorder' => 'DESC', 'limit' => 5, 'sqlfilters' => 'fk_soc:=:'.$socId])
+            ->with('invoices', ['sortfield' => 'datef', 'sortorder' => 'DESC', 'limit' => 5, 'sqlfilters' => "(fk_soc:=:$socId) and (fk_statut:!=:0)"])
             ->willReturn([['id' => 10], ['id' => 20]]);
 
         $this->assertEquals([['id' => 10], ['id' => 20]], $dolibarrApiService->getBills($socId));
@@ -193,7 +193,7 @@ class DolibarrApiServiceTest extends TestCase
         $dolibarrApiService
             ->expects(self::once())
             ->method('getJsonContent')
-            ->with('invoices', ['sortfield' => 'datef', 'sortorder' => 'DESC', 'limit' => 5, 'sqlfilters' => 'fk_soc:=:'.$socId])
+            ->with('invoices', ['sortfield' => 'datef', 'sortorder' => 'DESC', 'limit' => 5, 'sqlfilters' => "(fk_soc:=:$socId) and (fk_statut:!=:0)"])
             ->willThrowException(new HttpException(404));
 
         $this->assertEquals([], $dolibarrApiService->getBills($socId));
@@ -214,7 +214,7 @@ class DolibarrApiServiceTest extends TestCase
         $dolibarrApiService
             ->expects(self::once())
             ->method('getJsonContent')
-            ->with('invoices', ['sortfield' => 'datef', 'sortorder' => 'DESC', 'limit' => 5, 'sqlfilters' => 'fk_soc:=:'.$socId])
+            ->with('invoices', ['sortfield' => 'datef', 'sortorder' => 'DESC', 'limit' => 5, 'sqlfilters' => "(fk_soc:=:$socId) and (fk_statut:!=:0)"])
             ->willThrowException(new HttpException(500));
 
         $this->expectException(HttpException::class);

+ 10 - 10
tests/Unit/Service/File/Storage/LocalStorageTest.php

@@ -40,9 +40,9 @@ class TestableLocalStorage extends LocalStorage
         return parent::getOrganizationAndPersonFromOwner($owner);
     }
 
-    public function getFilterFromSizeAndConfig(string $size, bool $configExist): string
+    public function getFilterFromSizeAndConfig(string $size, bool $crop = true): string
     {
-        return parent::getFilterFromSizeAndConfig($size, $configExist);
+        return parent::getFilterFromSizeAndConfig($size, $crop);
     }
 
     public function rrmDir(string $dirKey): void
@@ -188,7 +188,7 @@ class LocalStorageTest extends TestCase
 
         $this->assertEquals(
             'publicUrl/xyz',
-            $localStorage->getImageUrl($file, 'sm', false)
+            $localStorage->getImageUrl($file, 'sm', false, false)
         );
     }
 
@@ -222,7 +222,7 @@ class LocalStorageTest extends TestCase
 
         $this->assertEquals(
             'xyz',
-            $localStorage->getImageUrl($file, 'sm', true)
+            $localStorage->getImageUrl($file, 'sm', true, false)
         );
     }
 
@@ -247,7 +247,7 @@ class LocalStorageTest extends TestCase
         $this->imageFactory
             ->expects(self::once())
             ->method('createImageContent')
-            ->with($file, 'crop_sm');
+            ->with($file, 'crop_sm', false);
 
         $this->cacheManager
             ->method('resolve')
@@ -256,7 +256,7 @@ class LocalStorageTest extends TestCase
 
         $this->assertEquals(
             'publicUrl/xyz',
-            $localStorage->getImageUrl($file, 'sm', false)
+            $localStorage->getImageUrl($file, 'sm', false, false)
         );
     }
 
@@ -281,7 +281,7 @@ class LocalStorageTest extends TestCase
         $this->imageFactory
             ->expects(self::once())
             ->method('createImageContent')
-            ->with($file, 'crop_sm')
+            ->with($file, 'crop_sm', false)
             ->willThrowException(new \Exception('File not found'));
 
         $this->cacheManager
@@ -295,7 +295,7 @@ class LocalStorageTest extends TestCase
 
         $this->assertEquals(
             'publicUrl/images/missing-file.png',
-            $localStorage->getImageUrl($file, 'sm', false)
+            $localStorage->getImageUrl($file, 'sm', false, false)
         );
     }
 
@@ -320,7 +320,7 @@ class LocalStorageTest extends TestCase
         $this->imageFactory
             ->expects(self::once())
             ->method('createImageContent')
-            ->with($file, 'crop_sm')
+            ->with($file, 'crop_sm', false)
             ->willThrowException(new \Exception('File not found'));
 
         $this->cacheManager
@@ -329,7 +329,7 @@ class LocalStorageTest extends TestCase
 
         $this->assertEquals(
             'images/missing-file.png',
-            $localStorage->getImageUrl($file, 'sm', true)
+            $localStorage->getImageUrl($file, 'sm', true, false)
         );
     }