Skip to content

Commit cb2dd3b

Browse files
committed
unit test optimizations
1 parent 09ab83f commit cb2dd3b

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

tests/DataProvider/EventsDataProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<?php
1+
<?php
22
namespace Tests\DataProvider;
33
use GuzzleHttp\Psr7;
44

55
class EventsDataProvider {
6-
6+
77
public static function getAllCases(): array
88
{
99
return [
@@ -41,7 +41,7 @@ public static function getAcls()
4141

4242
public static function getMetadata($title)
4343
{
44-
return '[{"label":"Opencast Series Dublincore","flavor":"dublincore\/episode","fields":[{"id":"title","value":"PHP UNIT TEST_' . strtotime('now') . '_' . strtoupper($title) . '_{update_replace}"},{"id":"subjects","value":["This is default subject"]},{"id":"description","value":"This is a default description for video"},{"id":"startDate","value":"' . date('Y-m-d') . '"},{"id":"startTime","value":"' . date('H:i:s') . 'Z"}]}]';
44+
return '[{"label":"Opencast Event Dublincore","flavor":"dublincore\/episode","fields":[{"id":"title","value":"PHP UNIT TEST_' . strtotime('now') . '_' . strtoupper($title) . '_{update_replace}"},{"id":"subjects","value":["This is default subject"]},{"id":"description","value":"This is a default description for video"},{"id":"startDate","value":"' . date('Y-m-d') . '"},{"id":"startTime","value":"' . date('H:i:s') . 'Z"}]}]';
4545
}
4646

4747
public static function getProcessing()
@@ -69,4 +69,4 @@ public static function getVttFile()
6969
return Psr7\Utils::tryFopen(__DIR__ . '/test_files/video_test_de.vtt', 'r');
7070
}
7171
}
72-
?>
72+
?>

tests/Unit/OcEventsApiTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function create_and_update_event(string $createdEventIdentifier): string
101101
$this->assertContains($responseCreate['code'], [200, 201], 'Failure to create an event');
102102
$createdEventIdentifier = $responseCreate['body']->identifier;
103103
$this->assertNotEmpty($createdEventIdentifier);
104+
sleep(5);
104105

105106
$metadata = str_replace(
106107
'{update_replace}',

tests/Unit/OcGroupsApiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function empty_created_id(): string
4343
*/
4444
public function create_get_update_delete_group(string $identifier): string
4545
{
46-
$name = 'PHPUNIT_TESTING_GROUP';
46+
$name = 'PHPUNIT_TESTING_GROUP_' . uniqid();
4747
// Get the group.
4848
$response0 = $this->ocGroupsApi->get(strtolower($name));
4949
if ($response0['code'] == 404) {

tests/Unit/OcWorkflowsApiTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,21 @@ public function get_definition_run_update_delete_workflow(): void
3737
{
3838
$data = [];
3939
// Get event
40-
$response0 = $this->ocEventsApi->getAll();
40+
$response0 = $this->ocEventsApi->getAll(
41+
['withpublications' => true]
42+
);
4143
$this->assertSame(200, $response0['code'], 'Failure to get events for the workflows!');
4244
$events = $response0['body'];
43-
$event = $events[array_rand($events)];
45+
$event = null;
46+
foreach ($events as $ev) {
47+
if ($ev->status === "EVENTS.EVENTS.STATUS.PROCESSED") {
48+
$event = $ev;
49+
break;
50+
}
51+
}
52+
if (empty($event)) {
53+
$this->markTestSkipped('No proper event found to apply workflow!');
54+
}
4455
$this->assertNotEmpty($event);
4556
$data['event_identifier'] = $event->identifier;
4657

@@ -70,18 +81,22 @@ public function get_definition_run_update_delete_workflow(): void
7081
$this->assertSame(201, $response3['code'], 'Failure to create (run) a workflow');
7182
$workflowId = $response3['body'];
7283
$this->assertNotEmpty($workflowId);
84+
sleep(1);
7385

7486
// Get the workflow.
7587
$response4 = $this->ocWorkflowsApi->get($workflowId->identifier, true, true);
7688
$this->assertSame(200, $response4['code'], 'Failure to get a workflow');
89+
sleep(1);
7790

7891
// Update workflow.
7992
$response5 = $this->ocWorkflowsApi->update($workflowId->identifier, 'stopped');
8093
$this->assertSame(200, $response5['code'], 'Failure to update a workflow');
94+
sleep(1);
8195

8296
// Delete the workflow.
8397
$response6 = $this->ocWorkflowsApi->delete($workflowId->identifier);
8498
$this->assertSame(204, $response6['code'], 'Failure to delete a workflow');
99+
sleep(1);
85100
}
86101
}
87102
?>

0 commit comments

Comments
 (0)