@@ -45,7 +45,7 @@ protected function setUp(): void {
4545 }
4646
4747
48- public function dataEnable () {
48+ public static function dataEnable (): array {
4949 return [
5050 ['no ' , null , [], true , 'Encryption enabled ' , 'No encryption module is loaded ' ],
5151 ['yes ' , null , [], false , 'Encryption is already enabled ' , 'No encryption module is loaded ' ],
@@ -57,15 +57,8 @@ public function dataEnable() {
5757
5858 /**
5959 * @dataProvider dataEnable
60- *
61- * @param string $oldStatus
62- * @param string $defaultModule
63- * @param array $availableModules
64- * @param bool $isUpdating
65- * @param string $expectedString
66- * @param string $expectedDefaultModuleString
6760 */
68- public function testEnable ($ oldStatus , $ defaultModule , $ availableModules , $ isUpdating , $ expectedString , $ expectedDefaultModuleString ): void {
61+ public function testEnable (string $ oldStatus , ? string $ defaultModule , array $ availableModules , bool $ isUpdating , string $ expectedString , string $ expectedDefaultModuleString ): void {
6962 if ($ isUpdating ) {
7063 $ this ->config ->expects ($ this ->once ())
7164 ->method ('setAppValue ' )
@@ -79,27 +72,30 @@ public function testEnable($oldStatus, $defaultModule, $availableModules, $isUpd
7972 if (empty ($ availableModules )) {
8073 $ this ->config ->expects ($ this ->once ())
8174 ->method ('getAppValue ' )
82- ->with ('core ' , 'encryption_enabled ' , $ this ->anything ())
83- ->willReturn ($ oldStatus );
75+ ->willReturnMap ([
76+ ['core ' , 'encryption_enabled ' , 'no ' , $ oldStatus ],
77+ ]);
8478 } else {
8579 $ this ->config ->expects ($ this ->exactly (2 ))
8680 ->method ('getAppValue ' )
87- ->withConsecutive (
88- ['core ' , 'encryption_enabled ' , $ this ->anything ()],
89- ['core ' , 'default_encryption_module ' , $ this ->anything ()],
90- )->willReturnOnConsecutiveCalls (
91- $ oldStatus ,
92- $ defaultModule ,
93- );
81+ ->willReturnMap ([
82+ ['core ' , 'encryption_enabled ' , 'no ' , $ oldStatus ],
83+ ['core ' , 'default_encryption_module ' , null , $ defaultModule ],
84+ ]);
9485 }
9586
87+ $ calls = [
88+ [$ expectedString , 0 ],
89+ ['' , 0 ],
90+ [$ expectedDefaultModuleString , 0 ],
91+ ];
9692 $ this ->consoleOutput ->expects ($ this ->exactly (3 ))
9793 ->method ('writeln ' )
98- ->withConsecutive (
99- [ $ this -> stringContains ( $ expectedString )],
100- [ '' ],
101- [ $ this ->stringContains ( $ expectedDefaultModuleString )],
102- );
94+ ->willReturnCallback ( function ( string $ message , int $ level ) use (& $ calls ): void {
95+ $ call = array_shift ( $ calls );
96+ $ this -> assertStringContainsString ( $ call [ 0 ], $ message );
97+ $ this ->assertSame ( $ call [ 1 ], $ level );
98+ } );
10399
104100 self ::invokePrivate ($ this ->command , 'execute ' , [$ this ->consoleInput , $ this ->consoleOutput ]);
105101 }
0 commit comments