Created
January 23, 2019 09:46
-
-
Save lucatume/6e1cf9ff7c43677874501b0219fdb22b to your computer and use it in GitHub Desktop.
Codeception Acceptance Helper modified to add a saveHtmlSnapshot method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Helper; | |
// here you can define custom actions | |
// all public methods declared in helper class will be available in $I | |
class Acceptance extends \Codeception\Module { | |
public function saveHtmlSnapshot( string $snapshot = null ) { | |
$responseContent = $this->getModule( 'WPBrowser' )->_getResponseContent(); | |
$snapshots = codecept_output_dir( 'snapshots' ); | |
if ( ! is_dir( $snapshots ) && ! mkdir( $snapshots ) && ! is_dir( $snapshots ) ) { | |
throw new \RuntimeException( 'Could not create snapshots dir.' ); | |
} | |
$snapshot = $snapshot ?? date( 'Y-m-d-H-i-s' ); | |
file_put_contents( $snapshots . '/' . $snapshot . '.html', $responseContent ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment