Skip to content

Commit

Permalink
Bug: WhyCome does not save (#7275)
Browse files Browse the repository at this point in the history
# Description & Issue number it closes 
<!-- Please include a summary of the changes and the related issue.
Please also include relevant motivation and context. -->
- fix #7263, this was due to ORM changes
- added test for testing saving WhyCome


## Screenshots (if appropriate)
<!-- Before and after --> 

## How to test the changes?

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

<!-- Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce. Please also list any relevant
details for your test configuration -->

# Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
  • Loading branch information
DawoudIO authored Feb 24, 2025
2 parents 3b46b5e + 4c3ff2a commit 3e05253
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
12 changes: 11 additions & 1 deletion cypress/e2e/ui/people/standard.person.profile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ context("Person Profile", () => {

cy.get("#editWhyCame").click();
cy.url().should("contains", `WhyCameEditor.php?PersonID=${personId}`);
cy.get('tr:nth-child(1) textarea').clear().type('{backspace}');
cy.get('tr:nth-child(1) textarea').clear().type('I love the lord ');
cy.get('tr:nth-child(2) textarea').clear().type('{backspace}');
cy.get('tr:nth-child(2) textarea').clear().type('{backspace}');
cy.get('tr:nth-child(2) textarea').clear().type('the feeling of being included');
cy.get('tr:nth-child(3) textarea').clear().type('More Youth Meetings');
cy.get('tr:nth-child(4) textarea').clear().type('The website ');
cy.get('td > .btn-primary').click();

cy.url().should('contains', 'WhyCameEditor.php');
cy.contains('More Youth Meetings');

// TODO: add editing
});
});
30 changes: 12 additions & 18 deletions src/WhyCameEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,21 @@
$tSuggest = InputUtils::legacyFilterInput($_POST['Suggest']);
$tHearOfUs = InputUtils::legacyFilterInput($_POST['HearOfUs']);

// New input (add)
if (strlen($iWhyCameID) < 1) {
$whyCame = WhyCameQuery::create()->findOneByPerId($iPerson);
if ($whyCame === null) {
LoggerUtils::getAppLogger()->info("person id " . $iPerson . " whycame id null" );
$whyCame = new WhyCame();
$whyCame
->setPerId($iPerson)
->setJoin($tJoin)
->setCome($tCome)
->setSuggest($tSuggest)
->setHearOfUs($tHearOfUs);
$whyCame->save();
// Existing record (update)
} else {
$whyCame = WhyCameQuery::create()->findOneByPerId($iPerson);
$whyCame
->setJoin($tJoin)
->setCome($tCome)
->setSuggest($tSuggest)
->setHearOfUs($tHearOfUs);
$whyCame->save();
$whyCame->setPerId($iPerson);
}

$whyCame
->setJoin($tJoin)
->setCome($tCome)
->setSuggest($tSuggest)
->setHearOfUs($tHearOfUs);

$whyCame->save();

if (isset($_POST['Submit'])) {
// Check for redirection to another page after saving information: (ie. PledgeEditor.php?previousPage=prev.php?a=1;b=2;c=3)
if ($linkBack != '') {
Expand Down

0 comments on commit 3e05253

Please sign in to comment.