Commit ac07d82d authored by Tymoteusz Motylewski's avatar Tymoteusz Motylewski Committed by Christian Kuhn
Browse files

[TASK] Add unit tests for TemplateService->splitConfArray()

splitConfArray is a implementation of TypoScript optionSplit function.
This change adds some unit tests for the basic usage outlined
in the documentation.
see https://docs.typo3.org/typo3cms/TyposcriptReference/ObjectsAndProperties/Index.html#objects-optionsplit

Resolves: #69854
Releases: master
Change-Id: I1312039479b8c685af240224906d897d6c1d00d7
Reviewed-on: http://review.typo3.org/43358


Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent ce87c272
......@@ -182,4 +182,120 @@ class TemplateServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
$this->assertNull($this->templateService->getFileName('something/../else'));
}
public function splitConfDataProvider() {
return array(
array(
array('splitConfiguration' => 'a'),
3,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'a'),
2 => array('splitConfiguration' => 'a')
)
),
array(
array('splitConfiguration' => 'a || b || c'),
5,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'b'),
2 => array('splitConfiguration' => 'c'),
3 => array('splitConfiguration' => 'c'),
4 => array('splitConfiguration' => 'c')
)
),
array(
array('splitConfiguration' => 'a || b |*| c'),
5,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'b'),
2 => array('splitConfiguration' => 'c'),
3 => array('splitConfiguration' => 'c'),
4 => array('splitConfiguration' => 'c')
)
),
array(
array('splitConfiguration' => 'a || b |*| c |*| d || e'),
7,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'b'),
2 => array('splitConfiguration' => 'c'),
3 => array('splitConfiguration' => 'c'),
4 => array('splitConfiguration' => 'c'),
5 => array('splitConfiguration' => 'd'),
6 => array('splitConfiguration' => 'e')
)
),
array(
array('splitConfiguration' => 'a || b |*| c |*| d || e'),
4,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'b'),
2 => array('splitConfiguration' => 'd'),
3 => array('splitConfiguration' => 'e')
)
),
array(
array('splitConfiguration' => 'a || b |*| c |*| d || e'),
3,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'd'),
2 => array('splitConfiguration' => 'e')
)
),
array(
array('splitConfiguration' => 'a || b |*||*| c || d'),
7,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'b'),
2 => array('splitConfiguration' => 'b'),
3 => array('splitConfiguration' => 'b'),
4 => array('splitConfiguration' => 'b'),
5 => array('splitConfiguration' => 'c'),
6 => array('splitConfiguration' => 'd')
)
),
array(
array('splitConfiguration' => '|*||*| a || b'),
7,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'a'),
2 => array('splitConfiguration' => 'a'),
3 => array('splitConfiguration' => 'a'),
4 => array('splitConfiguration' => 'a'),
5 => array('splitConfiguration' => 'a'),
6 => array('splitConfiguration' => 'b')
)
),
array(
array('splitConfiguration' => 'a |*| b || c |*|'),
7,
array(
0 => array('splitConfiguration' => 'a'),
1 => array('splitConfiguration' => 'b'),
2 => array('splitConfiguration' => 'c'),
3 => array('splitConfiguration' => 'b'),
4 => array('splitConfiguration' => 'c'),
5 => array('splitConfiguration' => 'b'),
6 => array('splitConfiguration' => 'c')
)
),
);
}
/**
* @test
* @dataProvider splitConfDataProvider
* @see https://docs.typo3.org/typo3cms/TyposcriptReference/ObjectsAndProperties/Index.html#objects-optionsplit
*/
public function splitConfArraytest($configuration, $splitCount, $expected) {
$actual = $this->templateService->splitConfArray($configuration, $splitCount);
$this->assertSame($expected, $actual);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment