зеркало из https://github.com/nextcloud/cookbook.git
Fix issues with tests
Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Родитель
b619568345
Коммит
2ba0880552
|
@ -210,7 +210,7 @@ class FixInstructionsFilter extends AbstractJSONFilter {
|
|||
}
|
||||
|
||||
private function flattenHowToSection($item): array {
|
||||
if ($item['name'] && is_string($item['name'])) {
|
||||
if (array_key_exists('name', $item) && $item['name'] && is_string($item['name'])) {
|
||||
$ret = ['## ' . $item['name']];
|
||||
} else {
|
||||
$ret = ['## HowToSection'];
|
||||
|
@ -222,10 +222,6 @@ class FixInstructionsFilter extends AbstractJSONFilter {
|
|||
}
|
||||
|
||||
private function extractHowToStep($item) {
|
||||
if (! $this->jsonService->isSchemaObject($item, 'HowToStep', false)) {
|
||||
throw new InvalidRecipeException($this->l->t('Cannot parse recipe: Unknown object found during flattening of instructions.'));
|
||||
}
|
||||
|
||||
return $item['text'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,6 +160,42 @@ class FixInstructionsFilterTest extends TestCase {
|
|||
], ['a', 'b', 'c'], true
|
||||
];
|
||||
|
||||
yield 'HowToSections' => [
|
||||
[
|
||||
[
|
||||
'@type' => 'HowToSection',
|
||||
'name' => 'Foo',
|
||||
'itemListElement' => [
|
||||
[
|
||||
'@type' => 'HowToStep',
|
||||
'text' => 'a',
|
||||
],
|
||||
[
|
||||
'@type' => 'HowToStep',
|
||||
'text' => 'b',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'@type' => 'HowToSection',
|
||||
'itemListElement' => [
|
||||
[
|
||||
'@type' => 'HowToStep',
|
||||
'text' => 'c',
|
||||
],
|
||||
[
|
||||
'@type' => 'HowToStep',
|
||||
'text' => 'd',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'@type' => 'HowToStep',
|
||||
'text' => 'e',
|
||||
],
|
||||
], ['## Foo', 'a', 'b', '## HowToSection', 'c', 'd', 'e'], true
|
||||
];
|
||||
|
||||
yield 'Issue1210' => [
|
||||
['a', '', 'b'], ['a', 'b'], true
|
||||
];
|
||||
|
|
Загрузка…
Ссылка в новой задаче