mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	ExportInterface::getLabels should return a closure
This commit is contained in:
		| @@ -315,18 +315,13 @@ class CSVFormatter implements FormatterInterface | ||||
|         foreach ($results as $row) { | ||||
|             $line = array(); | ||||
|             foreach ($headers as $key) { | ||||
|                 if (!array_key_exists($row[$key], $labels[$key])) { | ||||
|                     throw new \LogicException("The value '".$row[$key]."' " | ||||
|                             . "is not available from the labels defined by aggregator or report. " | ||||
|                             . "The key provided by aggregator or report is '$key'"); | ||||
|                 } | ||||
|                  | ||||
|                 $line[] = $labels[$key][$row[$key]]; | ||||
|                 $line[] = call_user_func($labels[$key], $row[$key]); | ||||
|             } | ||||
|              | ||||
|             //append result | ||||
|             foreach ($resultsKeys as $key) { | ||||
|                 $line[] = $labels[$key][$row[$key]]; | ||||
|                 $line[] = call_user_func($labels[$key], $row[$key]); | ||||
|             } | ||||
|              | ||||
|             $r[] = $line; | ||||
|   | ||||
| @@ -574,7 +574,15 @@ class ExportManagerTest extends KernelTestCase | ||||
|                     Argument::is(array(0, 1)),  | ||||
|                     Argument::Type('array') | ||||
|                 ) | ||||
|                 ->willReturn(array( 1 => 1, 0 => 0)); | ||||
|                 ->willReturn(function($value) {  | ||||
|                     switch($value) { | ||||
|                         case 0:  | ||||
|                         case 1: | ||||
|                             return $value; | ||||
|                         default: throw new \RuntimeException(sprintf("The value %s is not valid", $value)); | ||||
|                     } | ||||
|                 }); | ||||
|                  | ||||
|         $export->getQueryKeys(Argument::Type('array'))->willReturn(array('export')); | ||||
|         $export->getTitle()->willReturn('dummy title'); | ||||
|         $exportManager->addExport($export->reveal(), 'dummy'); | ||||
| @@ -602,9 +610,14 @@ class ExportManagerTest extends KernelTestCase | ||||
|                     Argument::is(array('cat a', 'cat b')),  | ||||
|                     Argument::is(array()) | ||||
|                 ) | ||||
|                 ->willReturn(array( | ||||
|                 'cat a' => 'label cat a', 'cat b' => 'label cat b' | ||||
|             )); | ||||
|                 ->willReturn(function($value) { | ||||
|                     switch ($value) { | ||||
|                         case 'cat a' : return 'label cat a'; | ||||
|                         case 'cat b' : return 'label cat b'; | ||||
|                         default: | ||||
|                             throw new \RuntimeException(sprintf("This value (%s) is not valid", $value)); | ||||
|                     } | ||||
|                 }); | ||||
|         $aggregator->addRole()->willReturn(null); | ||||
|         //$aggregator->addRole()->shouldBeCalled(); | ||||
|         $exportManager->addAggregator($aggregator->reveal(), 'aggregator_foo'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user