Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit bbf9385

Browse files
author
sathielemann
committed
Add cleanup logic for glossary tests which use the shared glossary API as resource.
1 parent 937c77d commit bbf9385

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/integration/GlossaryTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace BabyMarkt\DeepL\integration;
44

5-
use BabyMarkt\DeepL\DeepL;
65
use BabyMarkt\DeepL\Glossary;
6+
use DateTime;
77
use PHPUnit\Framework\TestCase;
88

99
class GlossaryTest extends TestCase
@@ -37,8 +37,19 @@ public static function tearDownAfterClass(): void
3737

3838
$glossariesResponse = $glossaryAPI->listGlossaries();
3939

40+
$fiveMinutesAgo = new DateTime(
41+
date(
42+
'Y-m-d H:i:s',
43+
time() - 60 * 5
44+
)
45+
);
46+
47+
// Cleanup old test fixtures in the deepl API. The 5 minute threashold is used to prevent parallel tests
48+
// execution intervention on the CI server.
4049
foreach ($glossariesResponse['glossaries'] as $glossary) {
41-
$glossaryAPI->deleteGlossary($glossary['glossary_id']);
50+
if (new DateTime($glossary['creation_time']) < $fiveMinutesAgo) {
51+
$glossaryAPI->deleteGlossary($glossary['glossary_id']);
52+
}
4253
}
4354
}
4455

0 commit comments

Comments
 (0)