Browse Source

fix remaining phpstan warnings and allow final class mocking

Olivier Massot 2 năm trước cách đây
mục cha
commit
86c99eff91

+ 1 - 0
composer.json

@@ -66,6 +66,7 @@
     },
     "require-dev": {
         "cyclonedx/cyclonedx-php-composer": "^3.4",
+        "dg/bypass-finals": "^1.4",
         "hautelook/alice-bundle": "^2.11",
         "phpstan/extension-installer": "^1.2",
         "phpstan/phpstan": "^1.9",

+ 1 - 1
src/Entity/Access/Access.php

@@ -416,7 +416,7 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
 
 
     /**
-     * @param bool[] $historical
+     * @param array<bool|string> $historical
      * @return $this
      */
     #[Groups(['my_access:input'])]

+ 7 - 1
src/Service/ApiLegacy/ApiLegacyRequestService.php

@@ -28,7 +28,13 @@ class ApiLegacyRequestService extends ApiRequestService
         parent::__construct($apiLegacyClient);
     }
 
-    /** @noinspection PhpPossiblePolymorphicInvocationInspection */
+    /**
+     * @param string $method
+     * @param string $url
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
+     * @noinspection PhpPossiblePolymorphicInvocationInspection
+     */
     public function request(
         string $method,
         string $url,

+ 19 - 0
src/Service/ApiResourceBuilder/Dolibarr/DolibarrAccountBuilder.php

@@ -52,6 +52,11 @@ class DolibarrAccountBuilder
         return $dolibarrAccount;
     }
 
+    /**
+     * @param int $organizationId
+     * @param array<mixed>|null $accountData
+     * @return DolibarrAccount
+     */
     public function createDolibarrAccount(int $organizationId, ?array $accountData): DolibarrAccount {
         $dolibarrAccount = new DolibarrAccount();
         $dolibarrAccount->setOrganizationId($organizationId);
@@ -73,6 +78,10 @@ class DolibarrAccountBuilder
         return $dolibarrAccount;
     }
 
+    /**
+     * @param array<mixed> $contractData
+     * @return DolibarrContract
+     */
     public function createDolibarrContract(array $contractData): DolibarrContract {
         $contract = new DolibarrContract();
         $contract->setRef($contractData['ref'] ?? '')
@@ -86,6 +95,11 @@ class DolibarrAccountBuilder
         return $contract;
     }
 
+    /**
+     * @param array<mixed> $lineData
+     * @return DolibarrContractLine
+     * @throws \Exception
+     */
     public function createDolibarrContractLine(array $lineData): DolibarrContractLine {
         $line = new DolibarrContractLine();
         return $line->setId((int)$lineData['id'])
@@ -96,6 +110,11 @@ class DolibarrAccountBuilder
                     ->setDateEnd(new \DateTime(date('c', (int)$lineData['date_end'])));
     }
 
+    /**
+     * @param array<mixed> $billData
+     * @return DolibarrBill
+     * @throws \Exception
+     */
     public function createDolibarrBill(array $billData): DolibarrBill {
         $bill = new DolibarrBill();
         return $bill->setId((int)$billData['id'])

+ 7 - 3
src/Service/Dolibarr/DolibarrApiService.php

@@ -26,7 +26,7 @@ class DolibarrApiService extends ApiRequestService
      * Get a dolibarr society by its opentalent organization id
      *
      * @param int $organizationId
-     * @return array|null
+     * @return array<mixed>|null
      * @throws \JsonException
      */
     public function getSociety(int $organizationId): ?array
@@ -48,7 +48,7 @@ class DolibarrApiService extends ApiRequestService
      * Get the first active contract for the given dolibarr society
      *
      * @param int $socId
-     * @return array|null
+     * @return array<mixed>|null
      */
     public function getActiveContract(int $socId): ?array
     {
@@ -70,7 +70,7 @@ class DolibarrApiService extends ApiRequestService
      * Get a society bills by their society id
      *
      * @param int $socId
-     * @return array
+     * @return array<mixed>
      */
     public function getBills(int $socId): array
     {
@@ -89,6 +89,8 @@ class DolibarrApiService extends ApiRequestService
 
     /**
      * Get all the societies which are Opentalent client
+     *
+     * @return array<mixed>
      * @throws HttpException
      */
     public function getAllClients(): array
@@ -102,6 +104,7 @@ class DolibarrApiService extends ApiRequestService
     /**
      * Get the society contacts
      *
+     * @return array<mixed>
      * @throws HttpException
      */
     public function getContacts(int $socId): array
@@ -123,6 +126,7 @@ class DolibarrApiService extends ApiRequestService
     /**
      * Get the society contacts that have a non-null personId
      *
+     * @return array<mixed>
      * @throws HttpException
      */
     public function getActiveOpentalentContacts(int $socId): array

+ 9 - 9
src/Service/Dolibarr/DolibarrSyncService.php

@@ -408,7 +408,7 @@ class DolibarrSyncService
     /**
      * Get the client societies dolibarr and index them by organization id
      *
-     * @return array An index of the form [$organizationId => $dolibarrData]
+     * @return array<mixed> An index of the form [$organizationId => $dolibarrData]
      */
     protected function getDolibarrSocietiesIndex(): array
     {
@@ -440,7 +440,7 @@ class DolibarrSyncService
      *
      * Index is the form: [$organizationId => [$accessId => [$mission, $mission...], $accessId...], $organizationId2...]
      *
-     * @return array
+     * @return array<mixed>
      */
     protected function getActiveMembersIndex(): array
     {
@@ -467,9 +467,9 @@ class DolibarrSyncService
      *
      * If none are found with the person id, try to find one with the same full name and no person id
      *
-     * @param array $dolibarrContacts
+     * @param array<mixed> $dolibarrContacts
      * @param Person $person
-     * @return array|null
+     * @return array<mixed>|null
      */
     protected function findDolibarrContactFor(array $dolibarrContacts, Person $person): ?array
     {
@@ -504,8 +504,8 @@ class DolibarrSyncService
      * As far as we know, there is no harm here to replace every empty string value by a null value
      * (no loss of information)
      *
-     * @param array|null $data
-     * @return array|null
+     * @param array<mixed>|null $data
+     * @return array<mixed>|null
      */
     protected function sanitizeDolibarrData(?array $data): ?array
     {
@@ -630,8 +630,8 @@ class DolibarrSyncService
     /**
      * Returns the number of accesses possessing at least one of the missions
      *
-     * @param array $missions A list of missions
-     * @param array $members An organization members as returned by getActiveMembersIndex: [$accessID => [$missions...]]
+     * @param array<mixed> $missions A list of missions
+     * @param array<mixed> $members An organization members as returned by getActiveMembersIndex: [$accessID => [$missions...]]
      * @return int
      */
     protected function countWithMission(array $missions, array $members): int
@@ -670,7 +670,7 @@ class DolibarrSyncService
     /**
      * Format the contact position from its gender and missions
      *
-     * @param array $missions
+     * @param list<string> $missions
      * @param string|null $gender
      * @return string
      */

+ 5 - 0
src/Service/Export/Encoder/EncoderInterface.php

@@ -7,5 +7,10 @@ interface EncoderInterface
 {
     public function support(string $format): bool;
 
+    /**
+     * @param string $html
+     * @param array<mixed> $options
+     * @return string
+     */
     public function encode(string $html, array $options = []): string;
 }

+ 3 - 3
src/Service/Export/Encoder/PdfEncoder.php

@@ -15,7 +15,7 @@ class PdfEncoder implements EncoderInterface
      * Default encoding options
      * @see https://wkhtmltopdf.org/libwkhtmltox/
      *
-     * @var array
+     * @var array<mixed>
      */
     private array $defaultOptions = [
         'margin-top'    => 35,
@@ -36,7 +36,7 @@ class PdfEncoder implements EncoderInterface
 
     /**
      * Default encoding options
-     * @return array
+     * @return array<mixed>
      */
     public function getDefaultOptions() {
         return $this->defaultOptions;
@@ -47,7 +47,7 @@ class PdfEncoder implements EncoderInterface
      * return the encoded content
      *
      * @param string $html
-     * @param array $options
+     * @param array<mixed> $options
      * @return string
      */
     public function encode(string $html, array $options = []): string

+ 3 - 3
src/Service/Export/Model/LicenceCmfCollection.php

@@ -8,12 +8,12 @@ class LicenceCmfCollection implements ExportModelInterface
     /**
      * Les différentes licences contenues dans la collection
      *
-     * @var array
+     * @var list<LicenceCmf>
      */
     private array $licences = [];
 
     /**
-     * @return array
+     * @return list<LicenceCmf>
      */
     public function getLicences(): array
     {
@@ -21,7 +21,7 @@ class LicenceCmfCollection implements ExportModelInterface
     }
 
     /**
-     * @param array $licences
+     * @param list<LicenceCmf> $licences
      */
     public function setLicences(array $licences): void
     {

+ 2 - 2
src/Service/File/Storage/LocalStorage.php

@@ -57,7 +57,7 @@ class LocalStorage implements FileStorageInterface
      *
      * @param Organization|Access|Person $owner
      * @param FileTypeEnum|null $type
-     * @return array
+     * @return list<string>
      */
     public function listByOwner (
         Organization | Access | Person $owner,
@@ -292,7 +292,7 @@ class LocalStorage implements FileStorageInterface
      * Return an array [$organization, $person] from a given owner
      *
      * @param Organization|Access|Person $owner
-     * @return array
+     * @return list<Organization | Person>
      */
     #[Pure]
     protected function getOrganizationAndPersonFromOwner(Organization | Access | Person $owner): array

+ 37 - 0
src/Service/Notifier.php

@@ -17,6 +17,14 @@ class Notifier
         private MercureHub $mercureHub
     ) {}
 
+    /**
+     * @param Access $access
+     * @param string $name
+     * @param string $type
+     * @param list<string> $message
+     * @param string|null $link
+     * @return Notification
+     */
     protected function createNotification(
         Access $access,
         string $name,
@@ -38,6 +46,14 @@ class Notifier
         return $notification;
     }
 
+    /**
+     * @param Access $access
+     * @param string $name
+     * @param string $type
+     * @param array<string> $message
+     * @param string|null $link
+     * @return Notification
+     */
     public function notify(
         Access $access,
         string $name,
@@ -56,6 +72,11 @@ class Notifier
         return $notification;
     }
 
+    /**
+     * @param Access $access
+     * @param File $file
+     * @return Notification
+     */
     public function notifyExport(
         Access $access,
         File $file
@@ -70,6 +91,11 @@ class Notifier
         );
     }
 
+    /**
+     * @param Access $access
+     * @param array<string> $message
+     * @return Notification
+     */
     public function notifyMessage(
         Access $access,
         array $message
@@ -83,6 +109,11 @@ class Notifier
         );
     }
 
+    /**
+     * @param Access $access
+     * @param  list<string> $message
+     * @return Notification
+     */
     public function notifySystem(
         Access $access,
         array $message
@@ -96,6 +127,12 @@ class Notifier
         );
     }
 
+    /**
+     * @param Access $access
+     * @param string $name
+     * @param list<string> $message
+     * @return Notification
+     */
     public function notifyError(
         Access $access,
         string $name,

+ 3 - 0
src/Service/OnChange/OnChangeContext.php

@@ -4,6 +4,9 @@ namespace App\Service\OnChange;
 
 class OnChangeContext
 {
+    /**
+     * @param array<mixed> $context
+     */
     public function __construct(
         private array $context
     ) {}

+ 15 - 15
src/Service/Rest/ApiRequestInterface.php

@@ -15,9 +15,9 @@ interface ApiRequestInterface
     /**
      * Sends a GET request and returns the response's body decoded as json
      * @param string $path
-     * @param array $parameters
-     * @param array $options
-     * @return array
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
+     * @return array<mixed>
      * @throws HttpException
      */
     public function getJsonContent(string $path, array $parameters = [], array $options = []): array;
@@ -26,8 +26,8 @@ interface ApiRequestInterface
      * Sends a GET request and returns the response's body
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return string
      * @throws HttpException
      */
@@ -37,8 +37,8 @@ interface ApiRequestInterface
      * Sends a GET request and returns the response
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */
@@ -48,8 +48,8 @@ interface ApiRequestInterface
      * Sends a POST request and returns the response
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */
@@ -59,8 +59,8 @@ interface ApiRequestInterface
      * Sends a PUT request and returns the response
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */
@@ -70,8 +70,8 @@ interface ApiRequestInterface
      * Sends a DELETE request and returns the response
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */
@@ -83,8 +83,8 @@ interface ApiRequestInterface
      *
      * @param string $method
      * @param string $url
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */

+ 15 - 15
src/Service/Rest/ApiRequestService.php

@@ -25,9 +25,9 @@ class ApiRequestService implements ApiRequestInterface
     /**
      * Sends a GET request and returns the response's body decoded as json
      * @param string $path
-     * @param array $parameters
-     * @param array $options
-     * @return array
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
+     * @return array<mixed>
      * @throws HttpException
      * @throws \JsonException
      */
@@ -40,8 +40,8 @@ class ApiRequestService implements ApiRequestInterface
      * Sends a GET request and returns the response's body
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return string
      * @throws HttpException
      */
@@ -58,8 +58,8 @@ class ApiRequestService implements ApiRequestInterface
      * Sends a GET request and returns the response
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */
@@ -72,8 +72,8 @@ class ApiRequestService implements ApiRequestInterface
      * Sends a POST request and returns the response
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */
@@ -86,8 +86,8 @@ class ApiRequestService implements ApiRequestInterface
      * Sends a PUT request and returns the response
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */
@@ -100,8 +100,8 @@ class ApiRequestService implements ApiRequestInterface
      * Sends a DELETE request and returns the response
      *
      * @param string $path
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */
@@ -116,8 +116,8 @@ class ApiRequestService implements ApiRequestInterface
      *
      * @param string $method
      * @param string $url
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      * @return ResponseInterface
      * @throws HttpException
      */

+ 18 - 4
src/Service/Rest/Operation/BaseRestOperation.php

@@ -28,6 +28,14 @@ abstract class BaseRestOperation
     protected int $status = self::STATUS_READY;
     protected string $errorMessage = "";
 
+    /**
+     * @param string $label
+     * @param string $method
+     * @param string $path
+     * @param array<mixed> $initialData
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
+     */
     public function __construct(
         protected string $label,
         protected string $method,
@@ -113,7 +121,7 @@ abstract class BaseRestOperation
     }
 
     /**
-     * @return array
+     * @return array<mixed>
      */
     public function getInitialData(): array
     {
@@ -121,7 +129,7 @@ abstract class BaseRestOperation
     }
 
     /**
-     * @return array
+     * @return array<mixed>
      */
     public function getParameters(): array
     {
@@ -129,7 +137,7 @@ abstract class BaseRestOperation
     }
 
     /**
-     * @return array
+     * @return array<mixed>
      */
     public function getOptions(): array
     {
@@ -139,7 +147,7 @@ abstract class BaseRestOperation
     /**
      * Return an array of messages describing the change that this operation will bring
      *
-     * @return array
+     * @return list<string>
      * @throws \Exception
      */
     abstract public function getChangeLog(): array;
@@ -149,6 +157,12 @@ abstract class BaseRestOperation
         return $this->getMethod() . " " . $this->getPath();
     }
 
+    /**
+     * @param array<mixed> $initialData
+     * @param array<mixed> $newData
+     * @param string $prefix
+     * @return array<mixed>
+     */
     protected static function getRecursiveChangeLog(array $initialData, array $newData, string $prefix = ""): array {
         $messages = [];
         foreach ($newData as $field => $newValue) {

+ 5 - 5
src/Service/Rest/Operation/CreateOperation.php

@@ -13,9 +13,9 @@ class CreateOperation extends BaseRestOperation
     /**
      * @param string $label A label for the operation
      * @param string $entityName The name of the entity to update. This will be used in the path of the request.
-     * @param array $data The data to update, will be post as Json within the request.
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $data The data to update, will be post as Json within the request.
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      */
     #[Pure]
     public function __construct(
@@ -46,7 +46,7 @@ class CreateOperation extends BaseRestOperation
     }
 
     /**
-     * @return array
+     * @return array<mixed>
      */
     public function getData(): array
     {
@@ -56,7 +56,7 @@ class CreateOperation extends BaseRestOperation
     /**
      * Return an array of messages describing the change that this operation will bring
      *
-     * @return array
+     * @return list<string>
      */
     public function getChangeLog(): array
     {

+ 6 - 3
src/Service/Rest/Operation/DeleteOperation.php

@@ -14,8 +14,8 @@ class DeleteOperation extends BaseRestOperation
      * @param string $label A label for the operation
      * @param string $entityName The name of the entity to update. This will be used in the path of the request.
      * @param int $id
-     * @param array $initialData The data of the existing object, before the update
-     * @param array $options
+     * @param array<mixed> $initialData The data of the existing object, before the update
+     * @param array<mixed> $options
      */
     #[Pure]
     public function __construct(
@@ -43,6 +43,9 @@ class DeleteOperation extends BaseRestOperation
         return $this->entityName;
     }
 
+    /**
+     * @return array<mixed>|null
+     */
     protected function getExpectedResult(): ?array {
         return null;
     }
@@ -50,7 +53,7 @@ class DeleteOperation extends BaseRestOperation
     /**
      * Return an array of messages describing the change that this operation will bring
      *
-     * @return array
+     * @return list<string>
      */
     public function getChangeLog(): array
     {

+ 6 - 6
src/Service/Rest/Operation/UpdateOperation.php

@@ -14,10 +14,10 @@ class UpdateOperation extends BaseRestOperation
      * @param string $label A label for the operation
      * @param string $entityName The name of the entity to update. This will be used in the path of the request.
      * @param int $id
-     * @param array $data The data to update, will be post as Json within the request.
-     * @param array $initialData The data of the existing object, before the update
-     * @param array $parameters
-     * @param array $options
+     * @param array<mixed> $data The data to update, will be post as Json within the request.
+     * @param array<mixed> $initialData The data of the existing object, before the update
+     * @param array<mixed> $parameters
+     * @param array<mixed> $options
      */
     #[Pure]
     public function __construct(
@@ -50,7 +50,7 @@ class UpdateOperation extends BaseRestOperation
     }
 
     /**
-     * @return array
+     * @return array<mixed>
      */
     public function getData(): array
     {
@@ -60,7 +60,7 @@ class UpdateOperation extends BaseRestOperation
     /**
      * Return an array of messages describing the change that this operation will bring
      *
-     * @return array
+     * @return list<string>
      */
     public function getChangeLog(): array
     {

+ 1 - 1
src/Service/Typo3/Typo3Service.php

@@ -21,7 +21,7 @@ class Typo3Service
      * Send a command to the given route of the Typo3 API
      *
      * @param string $route
-     * @param array<string, string|int> $parameters
+     * @param array<mixed> $parameters
      * @return ResponseInterface
      * @throws TransportExceptionInterface
      */

+ 1 - 1
src/Service/Utils/UrlBuilder.php

@@ -24,7 +24,7 @@ class UrlBuilder
      * Concatenate an url and a list of parameters
      *
      * @param string $url
-     * @param list<string> $parameters
+     * @param list<string | int> $parameters
      * @return string
      */
     public static function concatParameters(string $url, array $parameters = []): string

+ 22 - 16
tests/Service/Cron/UI/ConsoleUITest.php

@@ -2,16 +2,13 @@
 namespace App\Tests\Service\Cron\UI;
 
 use App\Service\Cron\UI\ConsoleUI;
+use PHPUnit\Framework\MockObject\MockObject;
 use PHPUnit\Framework\TestCase;
 use Symfony\Component\Console\Output\OutputInterface;
-
-class MockableProgressBar {
-    public function setProgress(int $step): void {}
-    public function setMaxSteps(int $max): void {}
-}
+use Symfony\Component\Console\Helper\ProgressBar;
 
 class TestableConsoleUI extends ConsoleUI {
-    public function setProgressBar(MockableProgressBar $progressBar): void
+    public function setProgressBar(ProgressBar $progressBar): void
     {
         $this->progressBar = $progressBar;
     }
@@ -23,15 +20,24 @@ class ConsoleUITest extends TestCase
 
     public function setUp(): void
     {
+        \DG\BypassFinals::enable();
         $this->output = $this->getMockBuilder(OutputInterface::class)->disableOriginalConstructor()->getMock();
     }
 
-    public function testPrint(): void
-    {
-        $consoleUI = $this->getMockBuilder(ConsoleUI::class)
+    /**
+     * @param list<string> $methodNames
+     * @return TestableConsoleUI | MockObject
+     */
+    private function getConsoleUiMockFor(array $methodNames): TestableConsoleUI | MockObject {
+        return $this->getMockBuilder(TestableConsoleUI::class)
             ->setConstructorArgs([$this->output])
-            ->setMethodsExcept(['print'])
+            ->setMethodsExcept($methodNames)
             ->getMock();
+    }
+
+    public function testPrint(): void
+    {
+        $consoleUI = $this->getConsoleUiMockFor(['print']);
 
         $this->output->expects(self::once())->method('writeln')->with('foo');
 
@@ -39,7 +45,8 @@ class ConsoleUITest extends TestCase
     }
 
     public function testProgress(): void {
-        $progressBar = $this->getMockBuilder(MockableProgressBar::class)->getMock();
+        /** @var ProgressBar | MockObject $progressBar */
+        $progressBar = $this->getMockBuilder(ProgressBar::class)->disableOriginalConstructor()->getMock();
 
         $consoleUI = $this->getMockBuilder(TestableConsoleUI::class)
             ->setConstructorArgs([$this->output])
@@ -58,12 +65,11 @@ class ConsoleUITest extends TestCase
     }
 
     public function testProgressEnd(): void {
-        $progressBar = $this->getMockBuilder(MockableProgressBar::class)->getMock();
+        /** @var ProgressBar | MockObject $progressBar */
+        $progressBar = $this->getMockBuilder(ProgressBar::class)->disableOriginalConstructor()->getMock();
+
+        $consoleUI = $this->getConsoleUiMockFor(['progress', 'setProgressBar']);
 
-        $consoleUI = $this->getMockBuilder(TestableConsoleUI::class)
-            ->setConstructorArgs([$this->output])
-            ->setMethodsExcept(['progress', 'setProgressBar'])
-            ->getMock();
         $consoleUI->setProgressBar($progressBar);
 
         $progressBar->expects(self::once())