Steps definitions to verify a downloaded file.
More...
|
| download_file (string $linktext, string $containerlocator, string $containertype) |
| Download a file from the given link.
|
|
| save_to_temp_file (string $filecontent, string $fileextension) |
| Save the downloaded file to tempdir and return the path.
|
|
| verify_file_contains_text (string $filecontent, string $expectedcontent) |
| Asserts that the given string is present in the file content.
|
|
| verify_file_mimetype (string $filecontent, string $expectedmimetype) |
| Validates the downloaded file appears to be of the mimetype.
|
|
| verify_xml_element_contains (string $filecontent, string $expectedcontent) |
| Asserts that the given XML file is valid and contains the expected string.
|
|
| verify_zip_file_content (string $filecontent, string $expectedfile) |
| Asserts that the given zip archive contains the expected file(s).
|
|
Steps definitions to verify a downloaded file.
- Copyright
- 2024 Simey Lameze simey.nosp@m.@moo.nosp@m.dle.c.nosp@m.om
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ download_file()
behat_download::download_file |
( |
string | $linktext, |
|
|
string | $containerlocator, |
|
|
string | $containertype ) |
|
protected |
Download a file from the given link.
- Parameters
-
string | $linktext | the text of the link. |
string | $containerlocator | the container element. |
string | $containertype | the container selector type. |
- Return values
-
- Exceptions
-
ExpectationException | if the download fails. |
◆ following_in_element_should_download_a_file_that()
behat_download::following_in_element_should_download_a_file_that |
( |
string | $linktext, |
|
|
string | $containerlocator, |
|
|
string | $containertype, |
|
|
TableNode | $table ) |
Downloads the file from a link on the page and verify the type and content.
@Then following :link_text in the :element_container_string :text_selector_string should download a file that:
- Parameters
-
string | $linktext | the text of the link. |
string | $containerlocator | the container element. |
string | $containertype | the container selector type. |
TableNode | $table | the table of assertions to use the check the file contents. |
- Exceptions
-
ExpectationException | if the file cannot be downloaded, or if the download does not pass all the checks. |
◆ following_should_download_a_file_that()
behat_download::following_should_download_a_file_that |
( |
string | $linktext, |
|
|
TableNode | $table ) |
Downloads the file from a link on the page and verify the type and content.
@Then following :link_text should download a file that:
- Parameters
-
string | $linktext | the text of the link. |
TableNode | $table | the table of assertions to use the check the file contents. |
- Exceptions
-
ExpectationException | if the file cannot be downloaded, or if the download does not pass all the checks. |
◆ getSession()
behat_session_interface::getSession |
( |
| $name = null | ) |
|
|
inherited |
Returns the Mink session.
- Parameters
-
string | null | $name | name of the session OR active session will be used |
- Return values
-
Implemented in behat_form_field.
◆ save_to_temp_file()
behat_download::save_to_temp_file |
( |
string | $filecontent, |
|
|
string | $fileextension ) |
|
protected |
Save the downloaded file to tempdir and return the path.
- Parameters
-
string | $filecontent | the content of the file. |
string | $fileextension | the expected file type, given as a file extension, e.g. 'txt', 'xml'. |
- Return values
-
string | path where the file was saved temporarily. |
◆ verify_file_contains_text()
behat_download::verify_file_contains_text |
( |
string | $filecontent, |
|
|
string | $expectedcontent ) |
|
protected |
Asserts that the given string is present in the file content.
- Parameters
-
string | $filecontent | the content of the file. |
string | $expectedcontent | the string to search for. |
- Exceptions
-
ExpectationException | if verification fails. |
◆ verify_file_mimetype()
behat_download::verify_file_mimetype |
( |
string | $filecontent, |
|
|
string | $expectedmimetype ) |
|
protected |
Validates the downloaded file appears to be of the mimetype.
- Parameters
-
string | $filecontent | the content of the file. |
string | $expectedmimetype | the expected file mimetype e.g. 'application/xml'. |
- Exceptions
-
ExpectationException | if the file does not appear to be of the expected type. |
◆ verify_xml_element_contains()
behat_download::verify_xml_element_contains |
( |
string | $filecontent, |
|
|
string | $expectedcontent ) |
|
protected |
Asserts that the given XML file is valid and contains the expected string.
- Parameters
-
string | $filecontent | the content of the file. |
string | $expectedcontent | the string to search for. |
- Exceptions
-
◆ verify_zip_file_content()
behat_download::verify_zip_file_content |
( |
string | $filecontent, |
|
|
string | $expectedfile ) |
|
protected |
Asserts that the given zip archive contains the expected file(s).
- Parameters
-
string | $filecontent | the content of the file. |
string | $expectedfile | the name of the file to search for. |
- Exceptions
-
ExpectationException | if the zip file does not contain the expected files. |
◆ PAGE_READY_JS
const behat_session_interface::PAGE_READY_JS |
|
inherited |
Initial value:= "document.readyState === 'complete' && " .
"(typeof M !== 'object' || typeof M.util !== 'object' || " .
"typeof M.util.pending_js === 'undefined' || M.util.pending_js.length === 0)"
The JS code to check that the page is ready.
The document must be complete and either M.util.pending_js must be empty, or it must not be defined at all.
The documentation for this class was generated from the following file:
- lib/tests/behat/behat_download.php