Skip to content

Commit

Permalink
Added a small test
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha committed Jan 20, 2025
1 parent 99ac62f commit 20a36be
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
24 changes: 24 additions & 0 deletions module/VuFind/tests/fixtures/configs/feedbackforms/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,27 @@ forms:
- name: message
type: textarea
label: Comments
TestWithNoFormActionRouteSet:
fields:
- name: name
type: text
label: Sender Name
- name: email
type: email
label: feedback_email
- name: message
type: textarea
label: Comments
TestWithFormActionRouteSet:
formActionRoute: 'test-action'
fields:
- name: name
type: text
label: Sender Name
- name: email
type: email
label: feedback_email
- name: message
type: textarea
label: Comments

35 changes: 35 additions & 0 deletions module/VuFind/tests/unit-tests/src/VuFindTest/Form/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,41 @@ public function testEmailSubjects(
);
}

/**
* Function to get form action route test data
*
* @return array
*/
public static function getFormActionRouteData(): array
{
return [
'with no route set' => [
'TestWithNoFormActionRouteSet',
'feedback-form',
],
'with route set' => [
'TestWithFormActionRouteSet',
'test-action',
],
];
}

/**
* Test formActionRoute setting
*
* @param string $id Form id
* @param string $expected Expected value
*
* @return void
*
* @dataProvider getFormActionRouteData
*/
public function testFormActionRoute(string $id, string $expected): void
{
$form = $this->getMockTestForm($id);
$this->assertEquals($expected, $form->getFormActionRoute());
}

/**
* Test prefilling values for inputs from form configuration
*
Expand Down

0 comments on commit 20a36be

Please sign in to comment.