Skip to content

Commit

Permalink
test: fix cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Oct 16, 2024
1 parent 12d4330 commit a78e11a
Showing 1 changed file with 37 additions and 17 deletions.
54 changes: 37 additions & 17 deletions tests/Qiniu/Tests/PfopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,17 @@ public function testPfopExecuteWithOptions()
$testCases = $this->pfopOptionsTestData();

foreach ($testCases as $testCase) {
if ($testCase['workflowTemplateID']) {
$workflowTemplateID = null;
$type = null;

if (array_key_exists('workflowTemplateID', $testCase)) {
$workflowTemplateID = $testCase['workflowTemplateID'];
}
if (array_key_exists('type', $testCase)) {
$type = $testCase['type'];
}

if ($workflowTemplateID) {
$fops = null;
} else {
$persistentEntry = \Qiniu\entry(
Expand All @@ -116,7 +126,7 @@ public function testPfopExecuteWithOptions()
array(
'test-pfop/test-pfop-by-api',
'type',
$testCase['type']
$type
)
)
);
Expand All @@ -129,24 +139,24 @@ public function testPfopExecuteWithOptions()
null,
null,
false,
$testCase['type'],
$testCase['workflowTemplateID']
$type,
$workflowTemplateID
);

if (in_array($testCase['type'], array(null, 0, 1))) {
if (in_array($type, array(null, 0, 1))) {
$this->assertNull($error);
list($status, $error) = $pfop->status($id);
$this->assertNotNull($status);
$this->assertNull($error);
if ($testCase['type'] == 1) {
if ($type == 1) {
$this->assertEquals(1, $status['type']);
}
if ($testCase['workflowTemplateID']) {
if ($workflowTemplateID) {
// assertStringContainsString when PHPUnit >= 8.0
$this->assertTrue(
strpos(
$status['taskFrom'],
$testCase['workflowTemplateID']
$workflowTemplateID
) !== false
);
}
Expand All @@ -166,11 +176,21 @@ public function testPfopWithUploadPolicy()
$testCases = $this->pfopOptionsTestData();

foreach ($testCases as $testCase) {
$workflowTemplateID = null;
$type = null;

if (array_key_exists('workflowTemplateID', $testCase)) {
$workflowTemplateID = $testCase['workflowTemplateID'];
}
if (array_key_exists('type', $testCase)) {
$type = $testCase['type'];
}

$putPolicy = array(
'persistentType' => $testCase['type']
'persistentType' => $type
);
if ($testCase['workflowTemplateID']) {
$putPolicy['persistentWorkflowTemplateID'] = $testCase['workflowTemplateID'];
if ($workflowTemplateID) {
$putPolicy['persistentWorkflowTemplateID'] = $workflowTemplateID;
} else {
$persistentEntry = \Qiniu\entry(
$bucket,
Expand All @@ -179,14 +199,14 @@ public function testPfopWithUploadPolicy()
array(
'test-pfop/test-pfop-by-upload',
'type',
$testCase['type']
$type
)
)
);
$putPolicy['persistentOps'] = 'avinfo|saveas/' . $persistentEntry;
}

if ($testCase['type'] == null) {
if ($type == null) {
unset($putPolicy['persistentType']);
}

Expand All @@ -206,7 +226,7 @@ public function testPfopWithUploadPolicy()
true
);

if (in_array($testCase['type'], array(null, 0, 1))) {
if (in_array($type, array(null, 0, 1))) {
$this->assertNull($error);
$this->assertNotEmpty($ret['persistentId']);
$id = $ret['persistentId'];
Expand All @@ -220,15 +240,15 @@ public function testPfopWithUploadPolicy()

$this->assertNotNull($status);
$this->assertNull($error);
if ($testCase['type'] == 1) {
if ($type == 1) {
$this->assertEquals(1, $status['type']);
}
if ($testCase['workflowTemplateID']) {
if ($workflowTemplateID) {
// assertStringContainsString when PHPUnit >= 8.0
$this->assertTrue(
strpos(
$status['taskFrom'],
$testCase['workflowTemplateID']
$workflowTemplateID
) !== false
);
}
Expand Down

0 comments on commit a78e11a

Please sign in to comment.