Files
piratepoet/packages/php/email-editor/tests/_support/IntegrationTester.php
Jan Lysý 113dbaae2d Change coding style in email editor tests to WordPress
This commit contains automated changes made with phpcbf command from CodeSniffer package.

[MAILPOET-6240]
2024-11-08 14:06:45 +01:00

53 lines
1.2 KiB
PHP

<?php declare(strict_types=1);
/**
* Inherited Methods
*
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause()
*
* @SuppressWarnings(PHPMD)
*/
class IntegrationTester extends \Codeception\Actor {
use _generated\IntegrationTesterActions;
private $wpTermIds = array();
private $createdCommentIds = array();
private $posts = array();
public function createPost( array $params ): \WP_Post {
$postId = wp_insert_post( $params );
if ( $postId instanceof WP_Error ) {
throw new \Exception( 'Failed to create post' );
}
$post = get_post( $postId );
if ( ! $post instanceof WP_Post ) {
throw new \Exception( 'Failed to fetch the post' );
}
$this->posts[] = $post;
return $post;
}
public function cleanup() {
$this->deletePosts();
}
private function deletePosts() {
foreach ( $this->posts as $post ) {
wp_delete_post( $post->ID, true );
}
}
}