From 4c3b93a56adca37d726052f2b7a327349dbc6de9 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Sat, 12 Oct 2024 15:50:58 +0100 Subject: [PATCH] Fixed verification error when expiry date element is present (#647) --- classes/output/verify_certificate_result.php | 4 +- ...fy_certificate_with_expiry_element.feature | 53 +++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 tests/behat/verify_certificate_with_expiry_element.feature diff --git a/classes/output/verify_certificate_result.php b/classes/output/verify_certificate_result.php index d376342a..c14541fd 100644 --- a/classes/output/verify_certificate_result.php +++ b/classes/output/verify_certificate_result.php @@ -62,9 +62,9 @@ class verify_certificate_result implements templatable, renderable { public string $certificatename; /** - * @var int|null The certificate's expiry date (optional). + * @var string|null The certificate's expiry date (optional). */ - public ?int $expiry; + public ?string $expiry; /** * Constructor. diff --git a/tests/behat/verify_certificate_with_expiry_element.feature b/tests/behat/verify_certificate_with_expiry_element.feature new file mode 100644 index 00000000..91c70b8a --- /dev/null +++ b/tests/behat/verify_certificate_with_expiry_element.feature @@ -0,0 +1,53 @@ +Feature: Being able to verify a certificate with an expiry element + In order to ensure expiry elements are working as expected + As a teacher + I need to verify a certificate with an expiry element + + Background: + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + | student1 | Student | 1 | student1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And the following "activities" exist: + | activity | name | intro | course | idnumber | verifyany | + | customcert | Custom certificate 1 | Custom certificate 1 intro | C1 | customcert1 | 0 | + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I follow "Custom certificate 1" + And I navigate to "Edit certificate" in current page administration + And I add the element "Code" to page "1" of the "Custom certificate 1" certificate template + And I set the following fields to these values: + | Font | Helvetica | + | Size | 20 | + | Colour | #045ECD | + | Width | 20 | + | Reference point location | Top left | + And I press "Save changes" + And I add the element "Expiry" to page "1" of the "Custom certificate 1" certificate template + And I set the following fields to these values: + | Date item | Expiry date (1 year) | + | Date format | 2 | + | Start date | award | + | Font | Helvetica | + | Size | 20 | + | Colour | #045ECD | + | Width | 20 | + | Reference point location | Top left | + And I press "Save changes" + + Scenario: Verify a certificate with an expiry element + Given I log in as "student1" + And I am on "Course 1" course homepage + When I follow "Custom certificate 1" + And I press "View certificate" + And I log out + And I log in as "teacher1" + And I visit the verification url for the "Custom certificate 1" certificate + Then I verify the "Custom certificate 1" certificate for the user "student1"