Commit 7cc16dbe authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fix unit test

parent 0c3e33ac
Pipeline #1522 failed with stage
in 2 minutes and 16 seconds
......@@ -20,7 +20,7 @@ $restForm=array();
try {
try {
$form = OnString::extractFormRecordId($_SERVER['PATH_INFO'], $restId, $restForm);
$form = OnString::splitPathInfoToIdForm($_SERVER['PATH_INFO'], $restId, $restForm);
$id=end($restId);
// Fake Bodytext setup
......
......@@ -217,7 +217,7 @@ class OnString {
* @return string
* @throws UserFormException
*/
public static function extractFormRecordId($pathInfo, array &$rcArrId, array &$rcArrForm) {
public static function splitPathInfoToIdForm($pathInfo, array &$rcArrId, array &$rcArrForm) {
// Empty: do nothing
if ($pathInfo == '') {
......
......@@ -83,24 +83,49 @@ class OnStringTest extends TestCase
* @throws UserFormException
*/
public function testExtractFormRecordId() {
$this->assertEquals('', OnString::extractFormRecordId(''));
$this->assertEquals('', OnString::extractFormRecordId('/'));
$this->assertEquals('', OnString::extractFormRecordId('//'));
$this->assertEquals(TYPO3_FORM . '=path1' . PHP_EOL, OnString::extractFormRecordId('/path1'));
$this->assertEquals(TYPO3_FORM . '=path1' . PHP_EOL, OnString::extractFormRecordId('/path1/'));
$this->assertEquals(TYPO3_FORM . '=path1' . PHP_EOL, OnString::extractFormRecordId('path1/'));
$arrId=array();
$arrForm=array();
$expected=TYPO3_RECORD_ID . '=12' . PHP_EOL . TYPO3_FORM . '=path1' . PHP_EOL;
$this->assertEquals($expected, OnString::extractFormRecordId('/path1/12'));
$this->assertEquals('', OnString::splitPathInfoToIdForm('', $arrId, $arrForm));
$this->assertEquals([], $arrId);
$this->assertEquals([], $arrForm);
$expected=TYPO3_RECORD_ID . '=12' . PHP_EOL . TYPO3_FORM . '=path1' . PHP_EOL;
$this->assertEquals($expected, OnString::extractFormRecordId('/path1/12/'));
$this->assertEquals('', OnString::splitPathInfoToIdForm('/', $arrId, $arrForm));
$this->assertEquals([], $arrId);
$this->assertEquals([], $arrForm);
$expected=TYPO3_FORM . '=path2' . PHP_EOL . TYPO3_REST_PATH . '=path1/12'. PHP_EOL;
$this->assertEquals($expected, OnString::extractFormRecordId('/path1/12/path2'));
$this->assertEquals('', OnString::splitPathInfoToIdForm('//', $arrId, $arrForm));
$this->assertEquals([], $arrId);
$this->assertEquals([], $arrForm);
$this->assertEquals('path1', OnString::splitPathInfoToIdForm('/path1', $arrId, $arrForm));
$this->assertEquals([0], $arrId);
$this->assertEquals(['path1'], $arrForm);
$this->assertEquals('path1', OnString::splitPathInfoToIdForm('/path1/', $arrId, $arrForm));
$this->assertEquals([0], $arrId);
$this->assertEquals(['path1'], $arrForm);
$this->assertEquals('path1', OnString::splitPathInfoToIdForm('path1/', $arrId, $arrForm));
$this->assertEquals([0], $arrId);
$this->assertEquals(['path1'], $arrForm);
$this->assertEquals('path1', OnString::splitPathInfoToIdForm('/path1/12', $arrId, $arrForm));
$this->assertEquals([12], $arrId);
$this->assertEquals(['path1'], $arrForm);
$this->assertEquals('path1', OnString::splitPathInfoToIdForm('/path1/12/', $arrId, $arrForm));
$this->assertEquals([12], $arrId);
$this->assertEquals(['path1'], $arrForm);
$this->assertEquals('path2', OnString::splitPathInfoToIdForm('/path1/12/path2', $arrId, $arrForm));
$this->assertEquals([12,0], $arrId);
$this->assertEquals(['path1','path2'], $arrForm);
$this->assertEquals('path2', OnString::splitPathInfoToIdForm('/path1/12/path2/34', $arrId, $arrForm));
$this->assertEquals([12,34], $arrId);
$this->assertEquals(['path1','path2'], $arrForm);
$expected=TYPO3_RECORD_ID . '=34' . PHP_EOL . TYPO3_FORM . '=path2' . PHP_EOL . TYPO3_REST_PATH . '=path1/12'. PHP_EOL;
$this->assertEquals($expected, OnString::extractFormRecordId('/path1/12/path2/34'));
}
/**
......@@ -109,7 +134,7 @@ class OnStringTest extends TestCase
*/
public function testExtractFormRecordId_1() {
# An alnum string is requested as path
$this->assertEquals('', OnString::extractFormRecordId('/%'));
$this->assertEquals('', OnString::splitPathInfoToIdForm('/%'));
}
/**
......@@ -118,7 +143,7 @@ class OnStringTest extends TestCase
*/
public function testExtractFormRecordId_2() {
# A numerical value is requested as id
$this->assertEquals('', OnString::extractFormRecordId('/path1/path2'));
$this->assertEquals('', OnString::splitPathInfoToIdForm('/path1/path2'));
}
/**
......
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