Return the workflow definition cache component used by this workflow source or NULL
if no cache is used.
public getDefinitionCache ( ) : null | yii\caching\Cache | ||
return | null | yii\caching\Cache |
public function testConstructSuccess() { $this->specify('Workflow source construct default', function () { $src = new WorkflowFileSource(); expect($src->getClassMapByType(WorkflowFileSource::TYPE_WORKFLOW))->equals('raoul2000\\workflow\\base\\Workflow'); expect($src->getClassMapByType(WorkflowFileSource::TYPE_STATUS))->equals('raoul2000\\workflow\\base\\Status'); expect($src->getClassMapByType(WorkflowFileSource::TYPE_TRANSITION))->equals('raoul2000\\workflow\\base\\Transition'); expect($src->getDefinitionCache())->equals(null); expect($src->getDefinitionLoader())->notNull(); }); $this->specify('Workflow source construct with class map', function () { $src = new WorkflowFileSource(['classMap' => [WorkflowFileSource::TYPE_WORKFLOW => 'my\\namespace\\Workflow', WorkflowFileSource::TYPE_STATUS => 'my\\namespace\\Status', WorkflowFileSource::TYPE_TRANSITION => 'my\\namespace\\Transition']]); expect($src->getClassMapByType(WorkflowFileSource::TYPE_WORKFLOW))->equals('my\\namespace\\Workflow'); expect($src->getClassMapByType(WorkflowFileSource::TYPE_STATUS))->equals('my\\namespace\\Status'); expect($src->getClassMapByType(WorkflowFileSource::TYPE_TRANSITION))->equals('my\\namespace\\Transition'); }); $this->specify('Workflow source construct with cache', function () { // initialized by array $src = new WorkflowFileSource(['definitionCache' => ['class' => 'yii\\caching\\FileCache']]); expect_that($src->getDefinitionCache() instanceof yii\caching\FileCache); // initialized by component ID Yii::$app->set('myCache', ['class' => 'yii\\caching\\FileCache']); $src = new WorkflowFileSource(['definitionCache' => 'myCache']); expect_that($src->getDefinitionCache() instanceof yii\caching\FileCache); // initialized by object $cache = Yii::$app->get('myCache'); Yii::$app->set('myCache', ['class' => 'yii\\caching\\FileCache']); $src = new WorkflowFileSource(['definitionCache' => $cache]); expect_that($src->getDefinitionCache() instanceof yii\caching\FileCache); }); }