1111use PHPUnit \Framework \TestCase ;
1212use RuntimeException ;
1313
14- abstract class BaseIntegrationTest extends TestCase
15- {
14+ abstract class BaseIntegrationTest extends TestCase {
1615 protected string $ hostname ;
1716 protected string $ folderPrefix ;
1817 protected string $ testUser ;
@@ -25,8 +24,7 @@ abstract class BaseIntegrationTest extends TestCase
2524
2625 protected static bool $ setupCompleted = false ;
2726
28- protected function setUp (): void
29- {
27+ protected function setUp (): void {
3028 parent ::setUp ();
3129
3230 // Load environment variables
@@ -46,8 +44,7 @@ protected function setUp(): void
4644 }
4745 }
4846
49- protected function setupEnvironment (): void
50- {
47+ protected function setupEnvironment (): void {
5148 // Create temporary folder
5249 if (!is_dir ($ this ->folderPrefix )) {
5350 mkdir ($ this ->folderPrefix , 0755 , true );
@@ -82,8 +79,7 @@ protected function setupEnvironment(): void
8279 $ this ->executeDockerCommand ('php occ app:enable gdatavaas ' );
8380 }
8481
85- protected function executeDockerCommand (string $ command , array $ env = []): array
86- {
82+ protected function executeDockerCommand (string $ command , array $ env = []): array {
8783 $ envString = '' ;
8884 foreach ($ env as $ key => $ value ) {
8985 $ envString .= " --env {$ key }= \"{$ value }\"" ;
@@ -100,8 +96,7 @@ protected function executeDockerCommand(string $command, array $env = []): array
10096 ];
10197 }
10298
103- protected function makeHttpRequest (string $ method , string $ url , array $ options = []): array
104- {
99+ protected function makeHttpRequest (string $ method , string $ url , array $ options = []): array {
105100 $ client = HttpClientBuilder::buildDefault ();
106101 $ request = new Request ($ url , $ method );
107102
@@ -151,8 +146,7 @@ protected function makeHttpRequest(string $method, string $url, array $options =
151146 }
152147 }
153148
154- protected function uploadFileViaWebDAV (string $ username , string $ password , string $ filename , string $ content ): array
155- {
149+ protected function uploadFileViaWebDAV (string $ username , string $ password , string $ filename , string $ content ): array {
156150 $ url = "http:// {$ this ->hostname }/remote.php/dav/files/ {$ username }/ {$ filename }" ;
157151
158152 return $ this ->makeHttpRequest ('PUT ' , $ url , [
@@ -162,17 +156,15 @@ protected function uploadFileViaWebDAV(string $username, string $password, strin
162156 ]);
163157 }
164158
165- protected function deleteFileViaWebDAV (string $ username , string $ password , string $ filename ): array
166- {
159+ protected function deleteFileViaWebDAV (string $ username , string $ password , string $ filename ): array {
167160 $ url = "http:// {$ this ->hostname }/remote.php/dav/files/ {$ username }/ {$ filename }" ;
168161
169162 return $ this ->makeHttpRequest ('DELETE ' , $ url , [
170163 'auth ' => ['username ' => $ username , 'password ' => $ password ]
171164 ]);
172165 }
173166
174- protected function uploadFileFromDisk (string $ username , string $ password , string $ filename , string $ localPath ): array
175- {
167+ protected function uploadFileFromDisk (string $ username , string $ password , string $ filename , string $ localPath ): array {
176168 if (!file_exists ($ localPath )) {
177169 throw new RuntimeException ("File not found: {$ localPath }" );
178170 }
@@ -190,8 +182,7 @@ protected function uploadFileFromDisk(string $username, string $password, string
190182 ]);
191183 }
192184
193- protected function testGetEndpoint (string $ endpoint , string $ description , int $ expectedHttpStatus = 200 , string $ username = 'admin ' , string $ password = 'admin ' ): void
194- {
185+ protected function testGetEndpoint (string $ endpoint , string $ description , int $ expectedHttpStatus = 200 , string $ username = 'admin ' , string $ password = 'admin ' ): void {
195186 $ url = "http:// {$ this ->hostname }/apps/gdatavaas/ {$ endpoint }" ;
196187
197188 $ result = $ this ->makeHttpRequest ('GET ' , $ url , [
@@ -201,8 +192,7 @@ protected function testGetEndpoint(string $endpoint, string $description, int $e
201192 $ this ->assertEquals ($ expectedHttpStatus , $ result ['http_code ' ], "Failed: {$ description }" );
202193 }
203194
204- protected function testPostEndpoint (string $ endpoint , array $ data , string $ description , int $ expectedHttpStatus = 200 , string $ username = 'admin ' , string $ password = 'admin ' ): void
205- {
195+ protected function testPostEndpoint (string $ endpoint , array $ data , string $ description , int $ expectedHttpStatus = 200 , string $ username = 'admin ' , string $ password = 'admin ' ): void {
206196 $ url = "http:// {$ this ->hostname }/apps/gdatavaas/ {$ endpoint }" ;
207197
208198 $ result = $ this ->makeHttpRequest ('POST ' , $ url , [
@@ -214,32 +204,27 @@ protected function testPostEndpoint(string $endpoint, array $data, string $descr
214204 $ this ->assertEquals ($ expectedHttpStatus , $ result ['http_code ' ], "Failed: {$ description }" );
215205 }
216206
217- protected function assertContainsVirusFound (array $ response ): void
218- {
207+ protected function assertContainsVirusFound (array $ response ): void {
219208 $ this ->assertStringContainsString ('Virus found ' , $ response ['body ' ], 'Expected "Virus found" in response body ' );
220209 }
221210
222- protected function assertHttpCodeInRange (int $ httpCode , int $ min = 200 , int $ max = 299 ): void
223- {
211+ protected function assertHttpCodeInRange (int $ httpCode , int $ min = 200 , int $ max = 299 ): void {
224212 $ this ->assertGreaterThanOrEqual ($ min , $ httpCode , "HTTP code {$ httpCode } is below expected range {$ min }- {$ max }" );
225213 $ this ->assertLessThan ($ max + 1 , $ httpCode , "HTTP code {$ httpCode } is above expected range {$ min }- {$ max }" );
226214 }
227215
228- protected function getTagsForFile (string $ filePath ): array
229- {
216+ protected function getTagsForFile (string $ filePath ): array {
230217 $ result = $ this ->executeDockerCommand ("php occ gdatavaas:get-tags-for-file {$ filePath }" );
231218 return $ result ['output ' ];
232219 }
233220
234- protected function assertHasTag (string $ filePath , string $ expectedTag ): void
235- {
221+ protected function assertHasTag (string $ filePath , string $ expectedTag ): void {
236222 $ tags = $ this ->getTagsForFile ($ filePath );
237223 $ tagString = implode ("\n" , $ tags );
238224 $ this ->assertStringContainsString ($ expectedTag , $ tagString , "Expected tag ' {$ expectedTag }' not found in file tags " );
239225 }
240226
241- protected function assertTagCount (string $ filePath , int $ expectedCount ): void
242- {
227+ protected function assertTagCount (string $ filePath , int $ expectedCount ): void {
243228 $ tags = $ this ->getTagsForFile ($ filePath );
244229 // Filter out empty lines
245230 $ nonEmptyTags = array_filter ($ tags , function ($ line ) {
@@ -248,8 +233,7 @@ protected function assertTagCount(string $filePath, int $expectedCount): void
248233 $ this ->assertCount ($ expectedCount , $ nonEmptyTags , "Expected {$ expectedCount } tags, got " . count ($ nonEmptyTags ));
249234 }
250235
251- public static function tearDownAfterClass (): void
252- {
236+ public static function tearDownAfterClass (): void {
253237 parent ::tearDownAfterClass ();
254238
255239 // Clean up temporary files
@@ -259,8 +243,7 @@ public static function tearDownAfterClass(): void
259243 }
260244 }
261245
262- private static function removeDirectory (string $ dir ): void
263- {
246+ private static function removeDirectory (string $ dir ): void {
264247 if (!is_dir ($ dir )) {
265248 return ;
266249 }
0 commit comments