Migrate tests/_support folder to WordPress Coding Standard
[MAILPOET-6240]
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the MailPoet plugin tests.
|
||||||
|
*
|
||||||
|
* @package MailPoet\EmailEditor
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inherited Methods
|
* Inherited Methods
|
||||||
@@ -21,18 +27,40 @@ class IntegrationTester extends \Codeception\Actor {
|
|||||||
|
|
||||||
use _generated\IntegrationTesterActions;
|
use _generated\IntegrationTesterActions;
|
||||||
|
|
||||||
private $wpTermIds = array();
|
/**
|
||||||
|
* WP term ids.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $wp_term_ids = array();
|
||||||
|
|
||||||
private $createdCommentIds = array();
|
/**
|
||||||
|
* List of created comment ids.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $created_comment_ids = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of created posts.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
private $posts = array();
|
private $posts = array();
|
||||||
|
|
||||||
public function createPost( array $params ): \WP_Post {
|
/**
|
||||||
$postId = wp_insert_post( $params );
|
* Method for creating a post.
|
||||||
if ( $postId instanceof WP_Error ) {
|
*
|
||||||
|
* @param array $params - Post parameters.
|
||||||
|
* @return \WP_Post
|
||||||
|
* @throws \Exception - If the post creation fails.
|
||||||
|
*/
|
||||||
|
public function create_post( array $params ): \WP_Post {
|
||||||
|
$post_id = wp_insert_post( $params );
|
||||||
|
if ( $post_id instanceof WP_Error ) {
|
||||||
throw new \Exception( 'Failed to create post' );
|
throw new \Exception( 'Failed to create post' );
|
||||||
}
|
}
|
||||||
$post = get_post( $postId );
|
$post = get_post( $post_id );
|
||||||
if ( ! $post instanceof WP_Post ) {
|
if ( ! $post instanceof WP_Post ) {
|
||||||
throw new \Exception( 'Failed to fetch the post' );
|
throw new \Exception( 'Failed to fetch the post' );
|
||||||
}
|
}
|
||||||
@@ -40,11 +68,17 @@ class IntegrationTester extends \Codeception\Actor {
|
|||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cleanup() {
|
/**
|
||||||
$this->deletePosts();
|
* Method for cleaning up after the test.
|
||||||
|
*/
|
||||||
|
public function cleanup(): void {
|
||||||
|
$this->delete_posts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function deletePosts() {
|
/**
|
||||||
|
* Delete created posts.
|
||||||
|
*/
|
||||||
|
private function delete_posts(): void {
|
||||||
foreach ( $this->posts as $post ) {
|
foreach ( $this->posts as $post ) {
|
||||||
wp_delete_post( $post->ID, true );
|
wp_delete_post( $post->ID, true );
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the MailPoet plugin.
|
||||||
|
*
|
||||||
|
* @package MailPoet\EmailEditor
|
||||||
|
*/
|
||||||
|
|
||||||
use _generated\UnitTesterActions;
|
use _generated\UnitTesterActions;
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@ class Content_Renderer_Test extends \MailPoetTest {
|
|||||||
$this->diContainer->get( Email_Editor::class )->initialize();
|
$this->diContainer->get( Email_Editor::class )->initialize();
|
||||||
$this->diContainer->get( BlockTypesController::class )->initialize();
|
$this->diContainer->get( BlockTypesController::class )->initialize();
|
||||||
$this->renderer = $this->diContainer->get( Content_Renderer::class );
|
$this->renderer = $this->diContainer->get( Content_Renderer::class );
|
||||||
$this->emailPost = $this->tester->createPost(
|
$this->emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:paragraph --><p>Hello!</p><!-- /wp:paragraph -->',
|
'post_content' => '<!-- wp:paragraph --><p>Hello!</p><!-- /wp:paragraph -->',
|
||||||
)
|
)
|
||||||
|
@@ -51,7 +51,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
'themeController' => $themeControllerMock,
|
'themeController' => $themeControllerMock,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->emailPost = $this->tester->createPost(
|
$this->emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:paragraph --><p>Hello!</p><!-- /wp:paragraph -->',
|
'post_content' => '<!-- wp:paragraph --><p>Hello!</p><!-- /wp:paragraph -->',
|
||||||
)
|
)
|
||||||
|
@@ -18,7 +18,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItInlinesButtonDefaultStyles() {
|
public function testItInlinesButtonDefaultStyles() {
|
||||||
$emailPost = $this->tester->createPost(
|
$emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:button --><div class="wp-block-button"><a class="wp-block-button__link has-background wp-element-button">Button</a></div><!-- /wp:button -->',
|
'post_content' => '<!-- wp:button --><div class="wp-block-button"><a class="wp-block-button__link has-background wp-element-button">Button</a></div><!-- /wp:button -->',
|
||||||
)
|
)
|
||||||
@@ -34,7 +34,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testButtonDefaultStylesDontOverwriteUserSetStyles() {
|
public function testButtonDefaultStylesDontOverwriteUserSetStyles() {
|
||||||
$emailPost = $this->tester->createPost(
|
$emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:button {"backgroundColor":"white","textColor":"vivid-cyan-blue"} --><div class="wp-block-button"><a class="wp-block-button__link has-background wp-element-button">Button</a></div><!-- /wp:button -->',
|
'post_content' => '<!-- wp:button {"backgroundColor":"white","textColor":"vivid-cyan-blue"} --><div class="wp-block-button"><a class="wp-block-button__link has-background wp-element-button">Button</a></div><!-- /wp:button -->',
|
||||||
)
|
)
|
||||||
@@ -46,7 +46,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItInlinesHeadingFontSize() {
|
public function testItInlinesHeadingFontSize() {
|
||||||
$emailPost = $this->tester->createPost(
|
$emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:heading {"level":1,"style":{"typography":{"fontSize":"large"}}} --><h1 class="wp-block-heading">Hello</h1><!-- /wp:heading -->',
|
'post_content' => '<!-- wp:heading {"level":1,"style":{"typography":{"fontSize":"large"}}} --><h1 class="wp-block-heading">Hello</h1><!-- /wp:heading -->',
|
||||||
)
|
)
|
||||||
@@ -57,7 +57,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItInlinesHeadingColors() {
|
public function testItInlinesHeadingColors() {
|
||||||
$emailPost = $this->tester->createPost(
|
$emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:heading {"level":1, "backgroundColor":"black", "textColor":"luminous-vivid-orange"} --><h1 class="wp-block-heading has-luminous-vivid-orange-color has-black-background-color">Hello</h1><!-- /wp:heading -->',
|
'post_content' => '<!-- wp:heading {"level":1, "backgroundColor":"black", "textColor":"luminous-vivid-orange"} --><h1 class="wp-block-heading has-luminous-vivid-orange-color has-black-background-color">Hello</h1><!-- /wp:heading -->',
|
||||||
)
|
)
|
||||||
@@ -69,7 +69,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItInlinesParagraphColors() {
|
public function testItInlinesParagraphColors() {
|
||||||
$emailPost = $this->tester->createPost(
|
$emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:paragraph {style":{"color":{"background":"black", "text":"luminous-vivid-orange"}}} --><p class="has-luminous-vivid-orange-color has-black-background-color">Hello</p><!-- /wp:paragraph -->',
|
'post_content' => '<!-- wp:paragraph {style":{"color":{"background":"black", "text":"luminous-vivid-orange"}}} --><p class="has-luminous-vivid-orange-color has-black-background-color">Hello</p><!-- /wp:paragraph -->',
|
||||||
)
|
)
|
||||||
@@ -81,7 +81,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItInlinesListColors() {
|
public function testItInlinesListColors() {
|
||||||
$emailPost = $this->tester->createPost(
|
$emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:list {"backgroundColor":"black","textColor":"luminous-vivid-orange","style":{"elements":{"link":{"color":{"text":"var:preset|color|vivid-red"}}}}} -->
|
'post_content' => '<!-- wp:list {"backgroundColor":"black","textColor":"luminous-vivid-orange","style":{"elements":{"link":{"color":{"text":"var:preset|color|vivid-red"}}}}} -->
|
||||||
<ul class="has-black-background-color has-luminous-vivid-orange-color has-text-color has-background has-link-color"><!-- wp:list-item -->
|
<ul class="has-black-background-color has-luminous-vivid-orange-color has-text-color has-background has-link-color"><!-- wp:list-item -->
|
||||||
@@ -101,7 +101,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItInlinesColumnsColors() {
|
public function testItInlinesColumnsColors() {
|
||||||
$emailPost = $this->tester->createPost(
|
$emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '<!-- wp:columns {"backgroundColor":"vivid-green-cyan", "textColor":"black"} -->
|
'post_content' => '<!-- wp:columns {"backgroundColor":"vivid-green-cyan", "textColor":"black"} -->
|
||||||
<div class="wp-block-columns has-black-background-color has-luminous-vivid-orange-color"><!-- wp:column --><!-- /wp:column --></div>
|
<div class="wp-block-columns has-black-background-color has-luminous-vivid-orange-color"><!-- wp:column --><!-- /wp:column --></div>
|
||||||
@@ -115,7 +115,7 @@ class Renderer_Test extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testItInlinesColumnColors() {
|
public function testItInlinesColumnColors() {
|
||||||
$emailPost = $this->tester->createPost(
|
$emailPost = $this->tester->create_post(
|
||||||
array(
|
array(
|
||||||
'post_content' => '
|
'post_content' => '
|
||||||
<!-- wp:column {"verticalAlignment":"stretch","backgroundColor":"black","textColor":"luminous-vivid-orange"} -->
|
<!-- wp:column {"verticalAlignment":"stretch","backgroundColor":"black","textColor":"luminous-vivid-orange"} -->
|
||||||
|
Reference in New Issue
Block a user