[BUGFIX] Importing extensions from repository fails

If importing the extension list from TER, an incoming XML extension
row has a field 'category' that contains either a string like
'plugin' or a category number.
The list is persisted to the 'extension' repository. In the
database, the category is stored as integer. There is a mapping
function in the extension model to get the integer category
index from given XML input. The method is faulty and returns
strings instead of an index if the given category is a string
itself. This results in database errors during insert.

The patch fixes the method, renames it along the way and adds
unit tests to document desired behavior.

Change-Id: I601b84d0829f3d20a4cdd25a3f7f37e8128dbce1
Fixes: #46115
Releases: 6.1, 6.0
Reviewed-on: https://review.typo3.org/18805
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn