function WorkflowTest::testNumericIdSorting
Same name in other branches
- 9 core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testNumericIdSorting()
- 10 core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testNumericIdSorting()
- 11.x core/modules/workflows/tests/src/Unit/WorkflowTest.php \Drupal\Tests\workflows\Unit\WorkflowTest::testNumericIdSorting()
Test numeric IDs when added to a workflow.
File
-
core/
modules/ workflows/ tests/ src/ Unit/ WorkflowTest.php, line 125
Class
- WorkflowTest
- @coversDefaultClass \Drupal\workflows\Plugin\WorkflowTypeBase
Namespace
Drupal\Tests\workflows\UnitCode
public function testNumericIdSorting() {
$workflow = new Workflow([
'id' => 'test',
'type' => 'test_type',
], 'workflow');
$workflow_type = $workflow->getTypePlugin();
$workflow_type->addState('1', 'One');
$workflow_type->addState('2', 'Two');
$workflow_type->addState('3', 'ZZZ');
$workflow_type->addState('4', 'AAA');
$workflow_type->setStateWeight('1', 1);
$workflow_type->setStateWeight('2', 2);
$workflow_type->setStateWeight('3', 3);
$workflow_type->setStateWeight('4', 3);
// Ensure numeric states are correctly sorted by weight first, label second.
$this->assertEquals([
1,
2,
4,
3,
], array_keys($workflow_type->getStates()));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.