浏览代码

fix unit tests

Olivier Massot 9 月之前
父节点
当前提交
1e355c75c5

+ 0 - 1
src/Service/File/Storage/LocalStorage.php

@@ -161,7 +161,6 @@ class LocalStorage implements FileStorageInterface
             ->setName($filename)
             ->setOrganization($organization)
             ->setPerson($person)
-            ->setSlug(null)
             ->setType($type)
             ->setVisibility($visibility)
             ->setIsTemporaryFile($isTemporary)

+ 2 - 1
tests/Unit/Service/Cron/Job/CleanTempFilesTest.php

@@ -12,6 +12,7 @@ use App\Service\File\Storage\LocalStorage;
 use App\Service\Utils\DatesUtils;
 use Doctrine\DBAL\Connection;
 use Doctrine\ORM\AbstractQuery;
+use Doctrine\ORM\Query;
 use Doctrine\ORM\Query\Expr;
 use Doctrine\ORM\Query\Expr\Comparison;
 use Doctrine\ORM\QueryBuilder;
@@ -142,7 +143,7 @@ class CleanTempFilesTest extends TestCase
             ->with($queryBuilder, $maxDate);
 
         // Mock la méthode getQuery() et getResult() pour renvoyer un tableau vide
-        $query = $this->getMockBuilder(AbstractQuery::class)
+        $query = $this->getMockBuilder(Query::class)
             ->disableOriginalConstructor()
             ->getMock();
 

+ 0 - 43
tests/Unit/Service/Elasticsearch/EducationNotationUpdaterTest.php

@@ -1,43 +0,0 @@
-<?php
-
-namespace App\Tests\Unit\Service\Elasticsearch;
-
-use App\Service\Elasticsearch\EducationNotationUpdater;
-use FOS\ElasticaBundle\Persister\ObjectPersister;
-use PHPUnit\Framework\TestCase;
-
-class TestableEducationNotationUpdater extends EducationNotationUpdater
-{
-    // To avoid the bug when mocking classes with only one method;
-    // can be removed when the tested class will have at least 2 methods
-    public function foo(): void
-    {
-    }
-}
-
-class EducationNotationUpdaterTest extends TestCase
-{
-    private ObjectPersister $objectPersister;
-
-    public function setUp(): void
-    {
-        $this->objectPersister = $this->getMockBuilder(ObjectPersister::class)->disableOriginalConstructor()->getMock();
-    }
-
-    /**
-     * @see EducationNotationUpdater::update()
-     */
-    public function testUpdate(): void
-    {
-        $educationNotationUpdater = $this->getMockBuilder(TestableEducationNotationUpdater::class)
-            ->setConstructorArgs([$this->objectPersister])
-            ->setMethodsExcept(['update'])
-            ->getMock();
-
-        $educationNotations = ['foo'];
-
-        $this->objectPersister->expects(self::once())->method('replaceMany')->with($educationNotations);
-
-        $educationNotationUpdater->update($educationNotations);
-    }
-}

+ 2 - 2
tests/Unit/Service/File/FileManagerTest.php

@@ -2,8 +2,8 @@
 
 namespace App\Tests\Unit\Service\File;
 
-use ApiPlatform\Api\IriConverterInterface;
-use ApiPlatform\Api\UrlGeneratorInterface;
+use ApiPlatform\Metadata\IriConverterInterface;
+use ApiPlatform\Metadata\UrlGeneratorInterface;
 use ApiPlatform\Metadata\Get;
 use App\Entity\Access\Access;
 use App\Entity\Core\File;

+ 0 - 1
tests/Unit/Service/File/Storage/LocalStorageTest.php

@@ -397,7 +397,6 @@ class LocalStorageTest extends TestCase
         $this->assertEquals($owner, $file->getOrganization());
         $this->assertEquals(null, $file->getPerson());
         $this->assertEquals('file.ext', $file->getName());
-        $this->assertEquals(null, $file->getSlug());
         $this->assertEquals(FileTypeEnum::LICENCE_CMF, $file->getType());
         $this->assertTrue($file->getIsTemporaryFile());
         $this->assertEquals(FileVisibilityEnum::ONLY_ORGANIZATION, $file->getVisibility());

+ 1 - 1
tests/Unit/Service/MercureHubTest.php

@@ -2,7 +2,7 @@
 
 namespace App\Tests\Unit\Service;
 
-use ApiPlatform\Api\IriConverterInterface;
+use ApiPlatform\Metadata\IriConverterInterface;
 use App\Entity\Organization\Organization;
 use App\Service\MercureHub;
 use PHPUnit\Framework\TestCase;