Skip to content

Commit 66a0b74

Browse files
authored
add update person tests to ensure functionality (#7034)
# Description & Issue number it closes <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. --> I was hoping to resolve #7026 but I didn't see the error, so I'm adding tests to update a created person to ensure functionality
2 parents 85c116a + cc947f5 commit 66a0b74

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
const personEditorPath = "PersonEditor.php";
2+
const personViewPath = "PersonView.php";
3+
14
context("Standard Person", () => {
5+
const uniqueSeed = Date.now().toString();
6+
27
it("Add Full Person", () => {
3-
const uniqueSeed = Date.now().toString();
48
const name = "Bobby " + uniqueSeed;
5-
cy.loginStandard("PersonEditor.php");
9+
10+
cy.loginStandard(personEditorPath);
611
cy.get("#Gender").select("1");
712
cy.get("#FirstName").type(name);
813
cy.get("#LastName").type("Hall");
@@ -13,19 +18,43 @@ context("Standard Person", () => {
1318
cy.get("#Classification").select("1");
1419
cy.get("#PersonSaveButton").click();
1520

16-
cy.url().should("contains", "PersonView.php");
21+
cy.url().should("contains", personViewPath);
22+
cy.contains(name);
23+
24+
// make sure edit works
25+
cy.get('#EditPerson').click();
26+
27+
cy.url().should("contains", personEditorPath);
28+
29+
cy.get("#BirthYear").clear().type("1980");
30+
cy.get("#Email").clear().type(`bobby${uniqueSeed}@example.com`);
31+
cy.get("#PersonSaveButton").click();
32+
33+
cy.url().should("contains", personViewPath);
1734
cy.contains(name);
35+
1836
});
1937

2038
it("Add Person only first and last name", () => {
21-
const uniqueSeed = Date.now().toString();
2239
const name = "Robby " + uniqueSeed;
23-
cy.loginStandard("PersonEditor.php");
40+
41+
cy.loginStandard(personEditorPath);
2442
cy.get("#FirstName").type(name);
2543
cy.get("#LastName").type("Hall");
2644
cy.get("#PersonSaveButton").click();
2745

28-
cy.url().should("contains", "PersonView.php");
46+
cy.url().should("contains", personViewPath);
47+
cy.contains(name);
48+
49+
// make sure edit works
50+
cy.get('#EditPerson').click();
51+
52+
cy.url().should("contains", personEditorPath);
53+
54+
cy.get("#Email").clear().type(`robby${uniqueSeed}@example.com`);
55+
cy.get("#PersonSaveButton").click();
56+
57+
cy.url().should("contains", personViewPath);
2958
cy.contains(name);
3059
});
3160
});

src/Include/Functions.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,16 @@ function ChopLastCharacter($sText): string
331331
return mb_substr($sText, 0, strlen($sText) - 1);
332332
}
333333

334-
function change_date_for_place_holder($string)
334+
function change_date_for_place_holder(string $string = null): string
335335
{
336-
return ((strtotime($string) != "") ? date(SystemConfig::getValue("sDatePickerFormat"), strtotime($string)) : strtotime($string));
336+
$string ??= '';
337+
$timestamp = strtotime($string);
338+
339+
if ($timestamp !== false) {
340+
return date(SystemConfig::getValue("sDatePickerFormat"), $timestamp);
341+
}
342+
343+
return '';
337344
}
338345

339346
function FormatDateOutput()

0 commit comments

Comments
 (0)