Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
7cc16dbe
Commit
7cc16dbe
authored
Feb 19, 2019
by
Carsten Rose
Browse files
Fix unit test
parent
0c3e33ac
Pipeline
#1522
failed with stage
in 2 minutes and 16 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
extension/Source/api/rest.php
View file @
7cc16dbe
...
...
@@ -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
...
...
extension/Source/core/helper/OnString.php
View file @
7cc16dbe
...
...
@@ -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
==
''
)
{
...
...
extension/Tests/unit/core/helper/OnStringTest.php
View file @
7cc16dbe
...
...
@@ -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'
));
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment