echo Html::dropDownList( 'status', null, WorkflowHelper::getAllStatusListData( $post->getWorkflow()->getId(), $post->getWorkflowSource() ) )
public static getAllStatusListData ( string $workflowId, IWorkflowSource $workflowSource ) : array | ||
$workflowId | string | |
$workflowSource | IWorkflowSource | |
리턴 | array |
public static function getAllStatusListData($workflowId, $workflowSource)
{
$listData = [];
$statuses = $workflowSource->getAllStatuses($workflowId);
foreach ($statuses as $statusId => $statusInstance) {
$listData[$statusId] = $statusInstance->getLabel();
}
return $listData;
}
public function testGetStatusDropDownData() { $model = new Item04(); $model->enterWorkflow(); $ar = WorkflowHelper::GetStatusDropDownData($model); $listData = WorkflowHelper::getAllStatusListData($model->getWorkflow()->getId(), $model->getWorkflowSource()); codecept_debug($ar); $expected = ['Item04Workflow/A' => 'Entry', 'Item04Workflow/B' => 'Published']; $this->assertTrue(is_array($ar)); $this->assertTrue(isset($ar['items']) && is_array($ar['items'])); $this->assertTrue(isset($ar['options']) && is_array($ar['options'])); $this->assertEquals(2, count($ar)); foreach ($listData as $status => $label) { $this->assertTrue(array_key_exists($status, $ar['items'])); } $this->assertTrue($ar['options']['Item04Workflow/C']['disabled']); $this->assertTrue($ar['options']['Item04Workflow/D']['disabled']); }